/* Custom styles for the story reading website */

/* Fairy Tale Classic Theme */
:root {
    --primary-color: #8B4513; /* Nâu cổ điển */
    --secondary-color: #DAA520; /* Vàng cổ điển */
    --accent-color: #CD853F; /* Nâu sáng */
    --background: #FFF8DC; /* Kem nhạt */
    --text: #2F4F4F; /* Xanh đậm */
    --light-color: #F5F5DC; /* Beige */
    --dark-color: #2F4F4F; /* Xanh đậm */
    --success-color: #228B22; /* Xanh lá đậm */
    --danger-color: #DC143C; /* Đỏ đậm */
    --warning-color: #FF8C00; /* Cam đậm */
    --info-color: #4682B4; /* Xanh thép */
}

/* Fairy Tale Special Effects */
.fairy-tale-border {
    border: 3px solid var(--accent-color);
    border-radius: 15px;
    position: relative;
}

.fairy-tale-border::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, var(--secondary-color), var(--accent-color), var(--primary-color));
    border-radius: 18px;
    z-index: -1;
}

.story-title {
    font-family: 'Roboto Slab', 'Rockwell', 'Courier New', serif;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.magical-hover {
    transition: all 0.3s ease;
}

.magical-hover:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.3);
}

/* General styles */
body {
    font-family: 'Roboto Slab', 'Rockwell', 'Courier New', serif;
    line-height: 1.6;
    background-color: var(--background);
    color: var(--text);
}

/* Ensure all text elements use Slab Serif fonts */
* {
    font-family: 'Roboto Slab', 'Rockwell', 'Courier New', serif;
}

/* Navigation */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
    color: var(--primary-color) !important;
    font-family: 'Roboto Slab', 'Rockwell', 'Courier New', serif;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: color 0.3s ease;
    color: var(--text) !important;
}

.navbar-nav .nav-link:hover {
    color: var(--primary-color) !important;
}

/* Cards */
.card {
    border: 2px solid var(--accent-color);
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 10px;
    background-color: var(--light-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.story-card {
    height: 100%;
}

.story-card .card-body {
    display: flex;
    flex-direction: column;
}

.story-card .card-title a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.story-card .card-title a:hover {
    color: #007bff;
}

/* Category sidebar */
.list-group-item {
    border: none;
    border-radius: 8px !important;
    margin-bottom: 2px;
    transition: all 0.3s ease;
}

.list-group-item:hover {
    background-color: #e9ecef;
    transform: translateX(5px);
}

.list-group-item.active {
    background-color: #007bff;
    border-color: #007bff;
}

/* Story content */
.story-content {
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.story-content p {
    margin-bottom: 1.5rem;
}

.story-content h1, .story-content h2, .story-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.story-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.5rem;
}

.story-content h2 {
    font-size: 1.5rem;
    color: #495057;
}

.story-content h3 {
    font-size: 1.25rem;
    color: #6c757d;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: var(--text);
}

/* Pagination */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: none;
    color: #007bff;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.pagination .page-link:hover {
    background-color: #007bff;
    color: #fff;
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}

/* Badges */
.badge {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
}

/* Search form */
.form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Footer */
footer {
    margin-top: auto;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
/* Tablet and mobile devices */
@media (max-width: 1023px) {
    /* Hide sidebar on tablet and mobile */
    .col-md-3 {
        display: none !important;
    }
    
    /* Adjust main content to full width on tablet and mobile */
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}


/* iPad Air specific styles (769px - 1023px) */
@media (min-width: 769px) and (max-width: 1023px) {
    /* Mobile menu fixes for tablet */
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
        font-size: 1.25rem;
        line-height: 1;
        background-color: transparent;
        border-radius: 0.375rem;
    }
    
    .navbar-toggler:focus {
        text-decoration: none;
        outline: 0;
        box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.25);
    }
    
    .navbar-toggler-icon {
        display: inline-block;
        width: 1.5em;
        height: 1.5em;
        vertical-align: middle;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100%;
    }
    
    .navbar-collapse {
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
        border: 2px solid var(--secondary-color);
        border-radius: 0.5rem;
        margin-top: 0.5rem;
        padding: 1rem;
        box-shadow: 0 4px 15px rgba(139, 69, 19, 0.3);
    }
    
    .navbar-nav {
        text-align: center;
    }
    
    .navbar-nav .nav-item {
        margin: 0.25rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
        color: var(--light-color) !important;
        background: rgba(139, 69, 19, 0.1);
        border: 1px solid transparent;
        margin: 0.25rem 0;
    }
    
    .navbar-nav .nav-link:hover {
        background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
        color: var(--dark-color) !important;
        transform: translateX(5px);
        border-color: var(--primary-color);
        box-shadow: 0 2px 8px rgba(139, 69, 19, 0.3);
    }
    
    .navbar .d-flex {
        margin-top: 1rem;
        flex-direction: column;
        width: 100%;
    }
    
    .navbar .d-flex .form-control {
        margin-bottom: 0.5rem;
        margin-right: 0;
        background-color: var(--light-color);
        border: 2px solid var(--accent-color);
        color: var(--dark-color);
        border-radius: 0.5rem;
    }
    
    .navbar .d-flex .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(139, 69, 19, 0.25);
        background-color: #fff;
    }
    
    .navbar .d-flex .btn {
        width: 100%;
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
        border: 2px solid var(--secondary-color);
        color: var(--light-color);
        border-radius: 0.5rem;
        font-weight: 600;
    }
    
    .navbar .d-flex .btn:hover {
        background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
        color: var(--dark-color);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
    }
    
    /* Mobile Categories Styling for tablet */
    .mobile-categories {
        margin: 1rem 0;
        padding: 1rem;
        background: linear-gradient(135deg, rgba(139, 69, 19, 0.15), rgba(205, 133, 63, 0.1));
        border-radius: 0.5rem;
        border: 2px solid var(--secondary-color);
        box-shadow: 0 2px 10px rgba(139, 69, 19, 0.2);
    }
    
    .mobile-categories h6 {
        font-weight: 600;
        margin-bottom: 1rem;
        color: var(--secondary-color) !important;
        text-align: center;
        border-bottom: 2px solid var(--secondary-color);
        padding-bottom: 0.5rem;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    }
    
    .categories-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        max-height: 300px;
        overflow-y: auto;
    }
    
    .category-link {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: var(--light-color) !important;
        text-decoration: none;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        font-weight: 500;
        background: rgba(139, 69, 19, 0.1);
    }
    
    .category-link:hover {
        background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
        color: var(--dark-color) !important;
        transform: translateX(5px) scale(1.02);
        border-color: var(--primary-color);
        box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
    }
    
    .category-link.active {
        background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
        color: var(--dark-color) !important;
        border-color: var(--primary-color);
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(139, 69, 19, 0.4);
    }
    
    .category-link i {
        width: 20px;
        text-align: center;
    }
    
    .category-link .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        margin-left: auto;
        background-color: var(--primary-color) !important;
        color: var(--light-color) !important;
        border: 1px solid var(--secondary-color);
    }
    
    /* Custom scrollbar for categories on tablet */
    .categories-list::-webkit-scrollbar {
        width: 4px;
    }
    
    .categories-list::-webkit-scrollbar-track {
        background: rgba(139, 69, 19, 0.1);
        border-radius: 2px;
    }
    
    .categories-list::-webkit-scrollbar-thumb {
        background: var(--accent-color);
        border-radius: 2px;
    }
    
    .categories-list::-webkit-scrollbar-thumb:hover {
        background: var(--secondary-color);
    }
}

@media (max-width: 768px) {
    /* Hide sidebar on mobile */
    .col-md-2 {
        display: none !important;
    }
    
    /* Adjust main content to full width on mobile */
    .col-md-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .story-card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .story-content {
        font-size: 1rem;
    }
    
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination .page-item {
        margin-bottom: 0.5rem;
    }
    
    /* Mobile menu fixes */
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
        font-size: 1.25rem;
        line-height: 1;
        background-color: transparent;
        border-radius: 0.375rem;
    }
    
    .navbar-toggler:focus {
        text-decoration: none;
        outline: 0;
        box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.25);
    }
    
    .navbar-toggler-icon {
        display: inline-block;
        width: 1.5em;
        height: 1.5em;
        vertical-align: middle;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100%;
    }
    
    .navbar-collapse {
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
        border: 2px solid var(--secondary-color);
        border-radius: 0.5rem;
        margin-top: 0.5rem;
        padding: 1rem;
        box-shadow: 0 4px 15px rgba(139, 69, 19, 0.3);
    }
    
    .navbar-nav {
        text-align: center;
    }
    
    .navbar-nav .nav-item {
        margin: 0.25rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
        color: var(--light-color) !important;
        background: rgba(139, 69, 19, 0.1);
        border: 1px solid transparent;
        margin: 0.25rem 0;
    }
    
    .navbar-nav .nav-link:hover {
        background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
        color: var(--dark-color) !important;
        transform: translateX(5px);
        border-color: var(--primary-color);
        box-shadow: 0 2px 8px rgba(139, 69, 19, 0.3);
    }
    
    .navbar .d-flex {
        margin-top: 1rem;
        flex-direction: column;
        width: 100%;
    }
    
    .navbar .d-flex .form-control {
        margin-bottom: 0.5rem;
        margin-right: 0;
        background-color: var(--light-color);
        border: 2px solid var(--accent-color);
        color: var(--dark-color);
        border-radius: 0.5rem;
    }
    
    .navbar .d-flex .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(139, 69, 19, 0.25);
        background-color: #fff;
    }
    
    .navbar .d-flex .btn {
        width: 100%;
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
        border: 2px solid var(--secondary-color);
        color: var(--light-color);
        border-radius: 0.5rem;
        font-weight: 600;
    }
    
    .navbar .d-flex .btn:hover {
        background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
        color: var(--dark-color);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
    }
    
    /* Mobile Categories Styling */
    .mobile-categories {
        margin: 1rem 0;
        padding: 1rem;
        background: linear-gradient(135deg, rgba(139, 69, 19, 0.15), rgba(205, 133, 63, 0.1));
        border-radius: 0.5rem;
        border: 2px solid var(--secondary-color);
        box-shadow: 0 2px 10px rgba(139, 69, 19, 0.2);
    }
    
    .mobile-categories h6 {
        font-weight: 600;
        margin-bottom: 1rem;
        color: var(--secondary-color) !important;
        text-align: center;
        border-bottom: 2px solid var(--secondary-color);
        padding-bottom: 0.5rem;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    }
    
    .categories-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        max-height: 300px;
        overflow-y: auto;
    }
    
    .category-link {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: var(--light-color) !important;
        text-decoration: none;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        font-weight: 500;
        background: rgba(139, 69, 19, 0.1);
    }
    
    .category-link:hover {
        background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
        color: var(--dark-color) !important;
        transform: translateX(5px) scale(1.02);
        border-color: var(--primary-color);
        box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
    }
    
    .category-link.active {
        background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
        color: var(--dark-color) !important;
        border-color: var(--primary-color);
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(139, 69, 19, 0.4);
    }
    
    .category-link i {
        width: 20px;
        text-align: center;
    }
    
    .category-link .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        margin-left: auto;
        background-color: var(--primary-color) !important;
        color: var(--light-color) !important;
        border: 1px solid var(--secondary-color);
    }
    
    /* Custom scrollbar for categories */
    .categories-list::-webkit-scrollbar {
        width: 4px;
    }
    
    .categories-list::-webkit-scrollbar-track {
        background: rgba(139, 69, 19, 0.1);
        border-radius: 2px;
    }
    
    .categories-list::-webkit-scrollbar-thumb {
        background: var(--accent-color);
        border-radius: 2px;
    }
    
    .categories-list::-webkit-scrollbar-thumb:hover {
        background: var(--secondary-color);
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* Animation for cards */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-card {
    animation: fadeInUp 0.6s ease-out;
}

/* Text selection */
::selection {
    background-color: #007bff;
    color: #fff;
}

::-moz-selection {
    background-color: #007bff;
    color: #fff;
}