/* Custom styles for the AI Story Generator */

/* Global text color fix - prevent white on white */
body, .card-body, .card, .alert, .bg-light {
    color: #212529 !important;
}

/* Fix for light backgrounds to ensure dark text */
.bg-light, .bg-light * {
    color: #212529 !important;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    body, .card-body, .card, .alert {
        color: #e0e0e0 !important;
    }
    
    .bg-light, .bg-light * {
        color: #212529 !important;
        background-color: #f8f9fa !important;
    }
}

/* Story content styling */
.story-content {
    background: #1a1a1a !important;
    border-radius: 0.375rem;
    padding: 1.5rem;
    border: 1px solid #444;
}

.story-text {
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    line-height: 1.7;
    text-align: justify;
    color: #e0e0e0 !important;
}

/* Ensure story result card body doesn't override */
.story-content p,
.story-content div,
.story-content span {
    color: #e0e0e0 !important;
}

/* Fix all text elements to ensure readability */
h1, h2, h3, h4, h5, h6, p, div, span, li, a, label, button {
    color: inherit;
}

/* Form enhancements */
.form-label {
    font-weight: 600;
    color: var(--bs-body-color);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Card styling */
.card {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

.card-header {
    background: var(--bs-dark);
    border-bottom: 1px solid var(--bs-border-color);
}


.dark-color {
    color: var(--bs-dark); 
}
/* Button enhancements */
.btn-primary {
    background: linear-gradient(135deg, var(--bs-primary), #0d6efd);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Loading states */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .story-text {
        font-size: 1rem;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Authentication section styling */
.alert-permanent {
    min-height: 80px;
}

.alert .d-flex {
    align-items: stretch;
}

.alert .btn {
    white-space: nowrap;
    min-width: 85px;
}

/* Better button spacing for auth buttons */
.d-flex.gap-2 .btn {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Mobile responsive buttons */
@media (max-width: 576px) {
    .alert .d-flex {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .alert .flex-grow-1 {
        margin-bottom: 0.5rem;
    }
    
    .d-flex.gap-2 {
        justify-content: center !important;
    }
    
    .d-flex.gap-2 .btn {
        flex: 1;
        min-width: 100px;
    }
}
.alert {
    border: 2px solid;
    font-weight: 500;
}

.alert-info {
    background-color: rgba(13, 202, 240, 0.1);
    border-color: rgba(13, 202, 240, 0.5);
    color: #0dcaf0;
}

.alert-success {
    background-color: rgba(25, 135, 84, 0.1);
    border-color: rgba(25, 135, 84, 0.5);
    color: #198754;
}

.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
    transform: translateY(-1px);
}

/* Form section spacing */
.mb-4:not(:last-child) {
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 1.5rem;
}

/* Character count helper */
.form-text {
    font-size: 0.875rem;
    color: var(--bs-secondary);
}

/* Alert styling */
.alert {
    border: none;
    border-radius: 0.5rem;
}

.alert-success {
    background: rgba(25, 135, 84, 0.1);
    color: var(--bs-success);
    border-left: 4px solid var(--bs-success);
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--bs-danger);
    border-left: 4px solid var(--bs-danger);
}

/* Footer styling */
footer {
    margin-top: auto;
}

/* Navbar enhancements */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

/* Smooth transitions */
.btn, .card, .alert {
    transition: all 0.2s ease-in-out;
}

/* Focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Icon fallbacks using SVG when Font Awesome fails to load */
.icon-fallback {
    display: inline-block;
    width: 1em;
    height: 1em;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* SVG fallback icons */
.icon-feather-fallback {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' fill='%23667ce4'%3E%3Cpath d='M278.5 215.6L23 471c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l74.8-74.8c7.4 4.6 15.3 8.2 23.8 10.5C200.3 457.8 240 512 240 512h40c0-88.4-71.6-160-160-160v-16c0-53 43-96 96-96h16v-16c0-88.4 71.6-160 160-160v-40c0 0-54.2 39.7-71.4 84.5-2.3 8.5-5.9 16.4-10.5 23.8L278.5 215.6z'/%3E%3C/svg%3E");
}

.icon-book-fallback {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512' fill='%23198754'%3E%3Cpath d='M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V64c0-35.3-28.7-64-64-64H96zM384 384H96c-17.7 0-32 14.3-32 32s14.3 32 32 32H384V384zM32 96c0-35.3 28.7-64 64-64H352c17.7 0 32 14.3 32 32V320c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V96z'/%3E%3C/svg%3E");
}

.icon-library-fallback {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512' fill='%230dcaf0'%3E%3Cpath d='M249.6 471.5c10.8 3.8 22.4-4.1 22.4-15.5V78.6c0-4.2-1.6-8.4-5-11C247.4 52 202.4 32 144 32C93.5 32 46.3 45.3 18.1 56.1C6.8 60.5 0 71.7 0 83.8V454.1c0 11.9 12.8 20.2 24.1 16.5C55.6 460.1 105.5 448 144 448c33.7 0 64.6 6.4 89.6 16.5zM558 56.1c-28.2-10.8-75.4-24.1-126-24.1c-58.4 0-103.4 20-122.9 35.6c-3.4 2.7-5 6.8-5 11V456c0 11.4 11.7 19.3 22.4 15.5c25-10.1 55.9-16.5 89.6-16.5c38.5 0 88.4 12.1 119.9 22.6c11.3 3.8 24.1-4.6 24.1-16.5V83.8c0-12.1-6.8-23.3-18.1-27.7z'/%3E%3C/svg%3E");
}

/* Large icon fallbacks for fa-4x size */
.fa-4x-fallback {
    width: 4em;
    height: 4em;
}

/* Font Awesome fallback detection */
@supports not (font-family: 'Font Awesome 6 Free') {
    .fas.fa-feather-alt::before {
        content: '';
        display: inline-block;
        width: 1em;
        height: 1em;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' fill='currentColor'%3E%3Cpath d='M278.5 215.6L23 471c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l74.8-74.8c7.4 4.6 15.3 8.2 23.8 10.5C200.3 457.8 240 512 240 512h40c0-88.4-71.6-160-160-160v-16c0-53 43-96 96-96h16v-16c0-88.4 71.6-160 160-160v-40c0 0-54.2 39.7-71.4 84.5-2.3 8.5-5.9 16.4-10.5 23.8L278.5 215.6z'/%3E%3C/svg%3E") no-repeat center;
        background-size: contain;
    }
    
    .fas.fa-book::before {
        content: '';
        display: inline-block;
        width: 1em;
        height: 1em;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512' fill='currentColor'%3E%3Cpath d='M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V64c0-35.3-28.7-64-64-64H96zM384 384H96c-17.7 0-32 14.3-32 32s14.3 32 32 32H384V384zM32 96c0-35.3 28.7-64 64-64H352c17.7 0 32 14.3 32 32V320c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V96z'/%3E%3C/svg%3E") no-repeat center;
        background-size: contain;
    }
    
    .fas.fa-book-open::before {
        content: '';
        display: inline-block;
        width: 1em;
        height: 1em;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512' fill='currentColor'%3E%3Cpath d='M249.6 471.5c10.8 3.8 22.4-4.1 22.4-15.5V78.6c0-4.2-1.6-8.4-5-11C247.4 52 202.4 32 144 32C93.5 32 46.3 45.3 18.1 56.1C6.8 60.5 0 71.7 0 83.8V454.1c0 11.9 12.8 20.2 24.1 16.5C55.6 460.1 105.5 448 144 448c33.7 0 64.6 6.4 89.6 16.5zM558 56.1c-28.2-10.8-75.4-24.1-126-24.1c-58.4 0-103.4 20-122.9 35.6c-3.4 2.7-5 6.8-5 11V456c0 11.4 11.7 19.3 22.4 15.5c25-10.1 55.9-16.5 89.6-16.5c38.5 0 88.4 12.1 119.9 22.6c11.3 3.8 24.1-4.6 24.1-16.5V83.8c0-12.1-6.8-23.3-18.1-27.7z'/%3E%3C/svg%3E") no-repeat center;
        background-size: contain;
    }
}
