/* =============================================
   Tutor-Pilot: Base Styles
   ============================================= */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Typography */
h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--gray-500); margin-bottom: 1.5rem; }

/* Navigation — Mac-style translucent bar */
.main-nav {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.75rem 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 200;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--gray-700);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
}

.nav-links > li > a:hover,
.nav-links > li > .nav-dropdown-toggle:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-dropdown-toggle::after {
    content: ' \25BE';
    font-size: 0.65em;
    opacity: 0.6;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    list-style: none;
    padding: 0.4rem;
    min-width: 170px;
    z-index: 100;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu li {
    margin: 0;
}

.nav-dropdown-menu li a {
    display: block;
    padding: 0.5rem 0.85rem;
    white-space: nowrap;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    transition: all 0.12s;
}

.nav-dropdown-menu li a:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-dropdown-menu li + li {
    margin-top: 2px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--gray-200);
}

.nav-user span {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
}

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

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border-color: var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover {
    background: var(--gray-100);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

/* Forms */
.form {
    max-width: 480px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group small {
    display: block;
    color: var(--gray-500);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Auth Pages */
.auth-container {
    max-width: 480px;
    margin: 3rem auto;
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.auth-container h1 {
    text-align: center;
}

.auth-container .subtitle {
    text-align: center;
}

.auth-links {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--gray-500);
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
}
.auth-links a:hover {
    text-decoration: underline;
}

/* Cards */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* Clickable stat cards */
a.stat-card-link {
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    display: block;
}
a.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}
a.stat-card-link .stat-value { color: var(--primary); }
a.stat-card-link .stat-label { color: var(--gray-500); }

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th:hover {
    background: var(--gray-100);
}

.data-table tr:hover {
    background: var(--gray-50);
}

.data-table .actions {
    white-space: nowrap;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-active { background: #dcfce7; color: var(--success); }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-expired { background: #fef2f2; color: var(--danger); }
.badge-trial { background: var(--primary-light); color: var(--primary); }

/* Table Filters */
.table-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.table-filters input,
.table-filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

/* File Preview Modal */
.file-preview-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
.file-preview-overlay.active {
    display: flex;
}
.file-preview-modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90vw;
    max-width: 900px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.file-preview-header .file-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-preview-header .file-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
.file-preview-body {
    flex: 1;
    overflow: hidden;
}
.file-preview-body iframe,
.file-preview-body img {
    width: 100%;
    height: 100%;
    border: none;
    object-fit: contain;
}

/* Footer */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1.25rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
    }

    .nav-user {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 0.5rem;
        border-top: 1px solid var(--gray-200);
        width: 100%;
    }

    .nav-dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border: none;
        padding: 0 0 0 1rem;
        min-width: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .auth-container {
        margin: 1rem;
    }
}
