/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #6a11cb;
    --secondary-color: #2575fc;
    --text-color: #ffffff;
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: #334155;
    --accent-color: #38bdf8;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    overflow: hidden;
    /* Prevent body scroll, handle in main-content */
}

/* Auth Pages (Center container) - one wrapper so toast is not a flex child */
body:not(:has(.dashboard-container)) {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.auth-page-wrap {
    flex: 1 1 auto;
    width: 100%;
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
}

.container {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

@media (max-width: 480px) {
    .container {
        margin: 12px;
        padding: 24px;
        max-width: none;
    }
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px;
    flex-shrink: 0;
}

.sidebar h2 {
    font-size: 24px;
    margin-bottom: 40px;
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
}

/* Logout link at bottom of sidebar - ensure visible on mobile when menu opens */
.sidebar .nav-link[href*="logout"] {
    margin-top: auto;
    flex-shrink: 0;
    margin-bottom:30px;
    
}

.main-content {
    flex: 1;
    padding: 30px;
    background-color: var(--bg-dark);
    overflow-y: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center children */
}

/* Constrain content width */
.main-content>* {
    width: 100%;
    max-width: 1100px;
}

/* Components */
h1 {
    font-size: 28px;
    margin-bottom: 25px;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.card {
    background-color: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    min-width: 0;
    overflow: hidden;
}

.card h3 {
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Forms */
input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    margin: 8px 0 20px 0;
    background-color: var(--bg-dark);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 15px;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.3s;
}

button:hover {
    opacity: 0.9;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

th {
    text-align: left;
    padding: 16px;
    color: #94a3b8;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

tr:last-child td {
    border-bottom: none;
}

/* Utilities */
.alert {
    padding: 16px;
    background: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fca5a5;
    border-radius: 8px;
    margin-bottom: 24px;
}

/* Toast notifications - fixed overlay at bottom-center (same as admin panel) */
#toastContainer,
#toastContainer.toast-container,
.toast-container {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 24px !important;
    transform: translateX(-50%) !important;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: min(380px, calc(100vw - 24px));
    width: max-content;
    min-width: 0;
    flex: none !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
}
.toast-container * {
    pointer-events: auto;
}
.toast {
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    animation: toastIn 0.35s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 100%;
}
.toast--success {
    background: rgba(34, 197, 94, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.toast--error {
    background: rgba(220, 38, 38, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.toast-message {
    flex: 1;
}
.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.8;
    cursor: pointer;
    padding: 4px;
    width: auto;
    font-size: 18px;
    line-height: 1;
}
.toast-close:hover {
    opacity: 1;
}
@keyframes toastIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Toast: mobile-friendly */
@media (max-width: 768px) {
    #toastContainer,
    .toast-container {
        left: 50% !important;
        right: auto !important;
        bottom: 12px !important;
        transform: translateX(-50%);
        max-width: calc(100vw - 24px);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .toast {
        padding: 14px 18px;
        font-size: 15px;
        min-height: 48px;
        min-width: 260px;
        -webkit-tap-highlight-color: transparent;
    }
    .toast-close {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        margin: -10px -8px -10px 0;
    }
}

/* Mobile dashboard: header with breadcrumb + hamburger, sidebar as overlay */
.mobile-dash-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0 16px;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    -webkit-tap-highlight-color: transparent;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    box-shadow: 0 6px 0 currentColor, 0 -6px 0 currentColor;
}

.breadcrumb-current {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive: mobile-first sidebar overlay */
@media (max-width: 768px) {
    .mobile-dash-header {
        display: flex;
    }

    .menu-toggle {
        display: flex;
    }

    .dashboard-container {
        flex-direction: row;
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.25s ease, box-shadow 0.25s ease;
        padding-top: 70px;
        padding-bottom: 24px;
        overflow-y: auto;
        overflow-x: hidden;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    .dashboard-container.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.25s ease;
    }

    .dashboard-container.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    .main-content {
        padding-top: 70px;
        width: 100%;
        flex: 1;
        min-height: 100vh;
    }

    body {
        overflow: auto;
    }

    body:has(.dashboard-container) {
        overflow: hidden;
    }

    body:has(.dashboard-container) .main-content {
        overflow-y: auto;
    }

    /* Keep cards and content inside viewport on mobile */
    .main-content {
        padding-left: 12px;
        padding-right: 12px;
        box-sizing: border-box;
        max-width: 100%;
        overflow-x: hidden;
    }

    .main-content > * {
        max-width: 100%;
        box-sizing: border-box;
    }

    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }

    /* Mobile tables: wide min-width so columns don't squeeze (avoids one letter per line) */
    .card table {
        min-width: 800px;
        table-layout: fixed;
    }

    /* User Management / other wide tables (9+ columns): extra width so content stays in one line, rely on horizontal scroll */
    .card.table-card--wide table {
        min-width: 1100px;
        table-layout: auto;
    }

    .card.table-card--wide th,
    .card.table-card--wide td {
        min-width: 6rem;
        white-space: nowrap;
    }

    /* Table headers: single line on mobile for a professional look */
    .main-content .card th {
        white-space: nowrap;
        min-width: 4rem;
    }

    /* Table cells: wrap normally, break only long words (no letter-by-letter) for regular tables */
    .main-content .card td {
        overflow-wrap: break-word;
        word-break: normal;
        min-width: 4rem;
    }

    .card > * {
        max-width: 100%;
    }

    /* Prevent long text/URLs from overflowing - use overflow-wrap only, avoid letter-by-letter break */
    .main-content h1,
    .main-content p,
    .main-content .card {
        overflow-wrap: break-word;
        word-break: normal;
    }

    .main-content td,
    .main-content th {
        overflow-wrap: break-word;
        word-break: normal;
    }
}