/**
 * StorySearch Plugin Styles
 * Modern, responsive design for the story search interface
 */

/* Container and Form Layout */
.storysearch-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

.storysearch-form {
    background: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e1e5e9;
    margin-bottom: 30px;
}

/* Form Fields */
.storysearch-field {
    margin-bottom: 25px;
}

.storysearch-field:last-child {
    margin-bottom: 0;
}

.storysearch-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Form Inputs */
.storysearch-field select,
.storysearch-field input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    background: #ffffff;
    transition: all 0.3s ease;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    cursor: text;
}

.storysearch-field select:focus,
.storysearch-field input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.storysearch-field select.focused,
.storysearch-field input[type="text"].focused {
    border-color: #3498db;
}

.storysearch-field select.error,
.storysearch-field input[type="text"].error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* Keyword input with multiple keywords styling */
.storysearch-field input[type="text"].has-multiple-keywords {
    border-color: #27ae60;
    background: linear-gradient(45deg, #ffffff 50%, rgba(39, 174, 96, 0.02) 50%);
}

/* Small helper text */
.storysearch-field small {
    display: block;
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
    position: relative;
    z-index: 0;
    pointer-events: none;
}

/* Search Button */
.storysearch-button {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.storysearch-button:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.storysearch-button:hover:before {
    left: 100%;
}

.storysearch-button:hover {
    background: linear-gradient(135deg, #2980b9, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
}

.storysearch-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
}

.storysearch-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.storysearch-button.enabled {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2); }
    50% { box-shadow: 0 6px 25px rgba(52, 152, 219, 0.4); }
    100% { box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2); }
}

/* Loading State */
.storysearch-loading {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 2px dashed #3498db;
    margin-bottom: 30px;
}

.storysearch-loading p {
    font-size: 18px;
    color: #3498db;
    font-weight: 500;
    margin: 0;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Results Container */
.storysearch-results {
    margin-top: 30px;
}

/* Story Display */
.storysearch-story {
    background: #ffffff;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #3498db;
    animation: slideInUp 0.6s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-title {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 20px 0;
    line-height: 1.3;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 15px;
}

.story-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.story-genre,
.story-length {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.story-length {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
}

.story-content {
    font-size: 16px;
    line-height: 1.8;
    color: #34495e;
    text-align: justify;
    margin-top: 25px;
}

.story-content p {
    margin-bottom: 15px;
}

/* Error Display */
.storysearch-error {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.storysearch-error p {
    margin: 0;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .storysearch-container {
        padding: 15px;
    }
    
    .storysearch-form {
        padding: 20px;
    }
    
    .storysearch-story {
        padding: 25px;
    }
    
    .story-title {
        font-size: 24px;
    }
    
    .story-meta {
        justify-content: center;
    }
    
    .storysearch-field select,
    .storysearch-field input[type="text"] {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .storysearch-form {
        padding: 15px;
    }
    
    .storysearch-story {
        padding: 20px;
    }
    
    .story-title {
        font-size: 20px;
    }
    
    .story-content {
        font-size: 15px;
    }
    
    .story-meta {
        flex-direction: column;
        align-items: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .storysearch-form,
    .storysearch-story {
        background: #0F0C17;
        border-color: #34495e;
        color: #ecf0f1;
    }
    
    .storysearch-field label {
        color: #ecf0f1;
    }
    
    .storysearch-field select,
    .storysearch-field input[type="text"] {
        background: #34495e;
        border-color: #495057;
        color: #ecf0f1;
    }
    
    .story-title {
        color: #ffffff;
        border-bottom-color: #495057;
    }
    
    .story-content {
        color: #bdc3c7;
    }
    
    .storysearch-loading {
        background: linear-gradient(45deg, #34495e, #2c3e50);
        border-color: #3498db;
    }
}

/* Print styles */
@media print {
    .storysearch-form,
    .storysearch-loading {
        display: none;
    }
    
    .storysearch-story {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* Accessibility improvements */
.storysearch-field select:focus-visible,
.storysearch-field input[type="text"]:focus-visible,
.storysearch-button:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .storysearch-form,
    .storysearch-story {
        border: 2px solid #000;
    }
    
    .storysearch-button {
        background: #000;
        border: 2px solid #000;
    }
    
    .storysearch-button:hover {
        background: #333;
    }
}