/* ============================================
   Islamic Lectures Portal - Custom Styling
   Theme: Sage & Beige with Moroccan Patterns
   ============================================ */

/* CSS Variables - Islamic Color Palette */
:root {
    --primary-sage: #6B7E65;
    --primary-sage-light: #8B9D83;
    --primary-sage-dark: #556654;
    --beige-light: #F5E6D3;
    --beige-medium: #E8D4B8;
    --beige-dark: #D4BC9E;
    --gold-accent: #C9A963;
    --text-dark: #2C3E2C;
    --text-muted: #6B7E65;
    --white: #FFFFFF;
    --shadow: rgba(107, 126, 101, 0.15);

    /* Moroccan Pattern (base64 encoded SVG) */
    --moroccan-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='moroccan' x='0' y='0' width='60' height='60' patternUnits='userSpaceOnUse'%3E%3Cpath d='M30 0 L35 15 L50 15 L38 24 L43 39 L30 30 L17 39 L22 24 L10 15 L25 15 Z' fill='%238B9D83' opacity='0.08'/%3E%3Ccircle cx='30' cy='30' r='3' fill='%23C9A963' opacity='0.05'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='60' height='60' fill='url(%23moroccan)'/%3E%3C/svg%3E");
}

/* Typography - Arabic-Friendly Fonts */
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Noto+Sans+Arabic:wght@300;400;600;700&display=swap');

body {
    font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--beige-light);
    background-image: var(--moroccan-pattern);
    background-attachment: fixed;
    color: var(--text-dark);
    line-height: 1.7;
}

h1, h2, h3, h4, h5, h6, .display-1, .display-2, .display-3, .display-4 {
    font-family: 'Amiri', serif;
    font-weight: 700;
    color: var(--primary-sage-dark);
}

/* Override Bootstrap Primary Colors */
.btn-primary {
    background-color: var(--primary-sage);
    border-color: var(--primary-sage);
    color: var(--white);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-sage-dark);
    border-color: var(--primary-sage-dark);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Outline Sage Button */
.btn-outline-sage {
    color: var(--primary-sage);
    border-color: var(--primary-sage);
    background-color: transparent;
}

.btn-outline-sage:hover, .btn-outline-sage:focus {
    color: var(--white);
    background-color: var(--primary-sage);
    border-color: var(--primary-sage);
}

.btn-check:checked + .btn-outline-sage {
    color: var(--white);
    background-color: var(--primary-sage);
    border-color: var(--primary-sage);
}

.bg-primary {
    background-color: var(--primary-sage) !important;
}

.badge.bg-primary {
    background-color: var(--primary-sage-light) !important;
    color: var(--white);
    padding: 0.35em 0.75em;
    font-weight: 500;
}

/* Navbar Styling */
.navbar {
    background: linear-gradient(135deg, var(--primary-sage) 0%, var(--primary-sage-dark) 100%);
    box-shadow: 0 2px 15px var(--shadow);
    padding: 1rem 0;
    border-bottom: 3px solid var(--gold-accent);
}

.navbar-brand {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--beige-light) !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.navbar-dark .navbar-nav .nav-link {
    color: var(--beige-light);
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: var(--gold-accent);
    transform: translateY(-1px);
}

/* Cards - Islamic Design */
.card {
    background: var(--white);
    border: 2px solid var(--beige-medium);
    border-radius: 8px;
    box-shadow: 0 4px 15px var(--shadow);
    transition: all 0.3s ease-in-out;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-sage) 0%, var(--gold-accent) 50%, var(--primary-sage) 100%);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px var(--shadow);
    border-color: var(--primary-sage-light);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    color: var(--primary-sage-dark);
    font-family: 'Amiri', serif;
    font-weight: 700;
    margin-bottom: 1rem;
}

.card-text {
    color: var(--text-dark);
    line-height: 1.6;
}

.card-text strong {
    color: var(--primary-sage);
}

.card-footer {
    background-color: var(--beige-light);
    border-top: 1px solid var(--beige-medium);
}

/* Search Bar Styling */
.search-container {
    background: linear-gradient(135deg, var(--beige-medium) 0%, var(--beige-light) 100%);
    padding: 2.5rem 2rem;
    border-radius: 12px;
    border: 2px solid var(--primary-sage-light);
    box-shadow: 0 4px 20px var(--shadow);
    margin-bottom: 2.5rem;
    position: relative;
}

.search-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--moroccan-pattern);
    opacity: 0.3;
    border-radius: 10px;
    pointer-events: none;
}

.search-container .form-control {
    border: 2px solid var(--primary-sage-light);
    border-radius: 8px 0 0 8px;
    padding: 0.75rem 1.25rem;
    font-size: 1.1rem;
    background-color: var(--white);
    color: var(--text-dark);
}

.search-container .form-control:focus {
    border-color: var(--primary-sage);
    box-shadow: 0 0 0 0.25rem rgba(107, 126, 101, 0.15);
    outline: none;
}

.search-container .btn {
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 2rem;
    font-weight: 600;
}

/* Section Headers with Decorative Elements */
.section-header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.section-header::after {
    content: '';
    display: block;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold-accent), transparent);
    margin: 1rem auto;
}

/* Decorative Separator */
.decorative-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0;
}

.decorative-separator::before,
.decorative-separator::after {
    content: '';
    flex: 1;
    border-bottom: 2px solid var(--beige-medium);
}

.decorative-separator::before {
    margin-right: 1rem;
}

.decorative-separator::after {
    margin-left: 1rem;
}

/* Audio Player Custom Styling */
audio {
    width: 100%;
    outline: none;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
}

audio::-webkit-media-controls-panel {
    background-color: var(--beige-light);
}

audio::-webkit-media-controls-play-button {
    background-color: var(--primary-sage);
    border-radius: 50%;
}

audio::-webkit-media-controls-timeline {
    background-color: var(--beige-medium);
    border-radius: 25px;
}

/* Buttons and Interactive Elements */
.btn-secondary {
    background-color: var(--beige-dark);
    border-color: var(--beige-dark);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: var(--primary-sage-light);
    border-color: var(--primary-sage-light);
    color: var(--white);
}

/* WhatsApp button - custom styling to match theme */
.btn-success {
    background-color: #25D366;
    border-color: #25D366;
    color: var(--white);
}

.btn-success:hover, .btn-success:focus {
    background-color: #1da851;
    border-color: #1da851;
    color: var(--white);
}

/* Sage themed action buttons */
.btn-sage {
    background-color: var(--primary-sage);
    border-color: var(--primary-sage);
    color: var(--white);
}

.btn-sage:hover, .btn-sage:focus {
    background-color: var(--primary-sage-dark);
    border-color: var(--primary-sage-dark);
    color: var(--white);
}

.btn-sage-danger {
    background-color: var(--beige-dark);
    border-color: var(--beige-dark);
    color: var(--text-dark);
}

.btn-sage-danger:hover, .btn-sage-danger:focus {
    background-color: #8B4513;
    border-color: #8B4513;
    color: var(--white);
}

.btn-sage-danger:disabled {
    background-color: var(--beige-medium);
    border-color: var(--beige-medium);
    color: var(--text-muted);
    opacity: 0.6;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
}

/* Links */
a {
    color: var(--primary-sage);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-sage-dark);
    text-decoration: underline;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 6px;
}

/* Forms */
.form-label {
    font-weight: 600;
    color: var(--primary-sage-dark);
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    border: 2px solid var(--beige-medium);
    border-radius: 6px;
    padding: 0.6rem 1rem;
    transition: border-color 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-sage);
    box-shadow: 0 0 0 0.25rem rgba(107, 126, 101, 0.15);
    outline: none;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #E8F5E9;
    border-color: var(--primary-sage);
    color: var(--primary-sage-dark);
}

.alert-info {
    background-color: var(--beige-light);
    border-color: var(--gold-accent);
    color: var(--text-dark);
}

.alert-danger {
    background-color: #FFEBEE;
    border-color: #C62828;
    color: #B71C1C;
}

/* Footer Styling */
footer {
    background: linear-gradient(135deg, var(--primary-sage-dark) 0%, var(--primary-sage) 100%);
    color: var(--beige-light);
    margin-top: auto;
    border-top: 3px solid var(--gold-accent);
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--moroccan-pattern);
    opacity: 0.15;
}

footer p {
    position: relative;
    z-index: 1;
}

/* Breadcrumb */
.breadcrumb {
    background-color: var(--beige-light);
    border: 1px solid var(--beige-medium);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--primary-sage);
}

.breadcrumb-item.active {
    color: var(--text-dark);
}

/* Tables */
.table {
    color: var(--text-dark);
    border-radius: 8px;
    overflow: hidden;
    border: none;
    background-color: transparent;
}

.table thead,
.table > thead {
    background-color: var(--primary-sage) !important;
    color: var(--white) !important;
    border: none;
}

.table thead th,
.table > thead > tr > th {
    border: none;
    padding: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--white) !important;
    background-color: var(--primary-sage) !important;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-color: rgba(245, 230, 211, 0.5);
}

.table tbody tr {
    border-bottom: 1px solid rgba(245, 230, 211, 0.5);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(245, 230, 211, 0.2) !important;
    color: var(--text-dark);
}

.table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: var(--white) !important;
    color: var(--text-dark);
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--beige-medium) !important;
    color: var(--text-dark);
}

/* Table wrapper for rounded corners */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow);
    border: 2px solid var(--primary-sage-light);
    background-color: var(--white);
}

/* Loading Spinner */
.upload-spinner {
    display: none;
}

.upload-spinner.show {
    display: inline-block;
}

.spinner-border {
    border-color: var(--primary-sage-light);
    border-right-color: transparent;
}

/* Dropdown Menus */
.dropdown-menu {
    border: 2px solid var(--beige-medium);
    border-radius: 6px;
    box-shadow: 0 4px 15px var(--shadow);
}

.dropdown-item:hover {
    background-color: var(--beige-light);
    color: var(--primary-sage-dark);
}

/* View Toggle Button */
.view-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-toggle-btn {
    background-color: var(--beige-medium);
    border: 2px solid var(--primary-sage-light);
    color: var(--primary-sage-dark);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.view-toggle-btn:hover {
    background-color: var(--primary-sage-light);
    color: var(--white);
    transform: translateY(-2px);
}

.view-toggle-btn.active {
    background-color: var(--primary-sage);
    color: var(--white);
    border-color: var(--primary-sage);
}

/* List View Styles */
.lecture-list-view {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.lecture-list-item {
    background: var(--white);
    border: 1px solid var(--beige-medium);
    border-bottom: 2px solid var(--beige-medium);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
    position: relative;
}

.lecture-list-item:first-child {
    border-radius: 8px 8px 0 0;
    border-top: 2px solid var(--primary-sage-light);
}

.lecture-list-item:last-child {
    border-radius: 0 0 8px 8px;
}

.lecture-list-item:hover {
    background-color: var(--beige-light);
    border-left: 4px solid var(--primary-sage);
    padding-left: calc(1rem - 3px);
}

.lecture-list-icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-sage-light), var(--primary-sage));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.5rem;
}

.lecture-list-info {
    flex: 1;
    min-width: 0;
}

.lecture-list-title {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-sage-dark);
    margin: 0 0 0.25rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lecture-list-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.lecture-list-meta strong {
    color: var(--primary-sage);
}

.lecture-list-meta .badge {
    font-size: 0.75rem;
    padding: 0.25em 0.6em;
    margin-left: 0.5rem;
}

.lecture-list-description {
    font-size: 0.85rem;
    color: var(--text-dark);
    margin: 0.5rem 0 0 0;
    line-height: 1.4;
}

.lecture-list-description.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more-btn, .card-read-more-btn {
    color: var(--primary-sage);
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
    margin-top: 0.25rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.read-more-btn:hover, .card-read-more-btn:hover {
    color: var(--primary-sage-dark);
    text-decoration: underline;
}

.lecture-list-action {
    flex-shrink: 0;
}

.lecture-list-action .btn {
    white-space: nowrap;
}

/* Card View Container */
.lecture-card-view {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}

.lecture-card-view > div {
    padding: 0 0.75rem;
}

/* Hide/Show Views */
.view-hidden {
    display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        font-size: 0.95rem;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    .search-container {
        padding: 1.5rem 1rem;
    }

    .search-container .form-control {
        font-size: 1rem;
        padding: 0.6rem 1rem;
    }

    .card-body {
        padding: 1rem;  /* Reduced from 1.25rem for more compact cards */
    }

    .card {
        margin-bottom: 1rem;  /* Reduced from 1.25rem */
    }

    .card:hover {
        transform: translateY(-4px);  /* Reduced hover lift from 8px */
    }

    .btn {
        padding: 0.5rem 1.25rem;
    }

    h1, .display-4 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    /* Larger touch targets for mobile */
    .btn-sm {
        padding: 0.5rem 1.25rem;
        font-size: 1rem;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
    }

    /* List view mobile optimizations */
    .lecture-list-item {
        padding: 0.75rem;
        flex-wrap: wrap;
    }

    .lecture-list-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .lecture-list-title {
        font-size: 1rem;
        white-space: normal;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .lecture-list-meta {
        font-size: 0.8rem;
    }

    .lecture-list-action {
        width: 100%;
        margin-top: 0.5rem;
    }

    .lecture-list-action .btn {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .search-container {
        padding: 1.25rem 0.75rem;
    }

    .search-container .btn {
        padding: 0.75rem 1.25rem;
    }

    .card {
        margin-bottom: 1.25rem;
    }

    .display-4 {
        font-size: 1.5rem;
    }
}

/* Smooth Transitions */
* {
    transition-property: background-color, border-color, color, transform;
    transition-duration: 0.2s;
    transition-timing-function: ease;
}

/* Print Styles */
@media print {
    body {
        background: white;
        background-image: none;
    }

    .navbar, footer, .btn {
        display: none;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}
