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

:root {
    --primary: #0f172a; /* Deep elegant blue */
    --primary-light: #1e3a8a;
    --accent: #e11d48; /* Vibrant red */
    --accent-hover: #be123c;
    --bg-main: #f4f4f5; 
    --surface: #ffffff;
    --text-primary: #0f172a; 
    --text-secondary: #475569; 
    --text-muted: #94a3b8; 
    --border: #e2e8f0; 
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-light);
}

a.btn-primary, a.btn-primary:hover, a.btn-success, a.btn-success:hover, a.btn-danger, a.btn-danger:hover {
    color: var(--surface);
}

a.btn-accent, a.btn-accent:hover {
    color: var(--primary);
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Typography Helpers */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }

/* Modern Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    letter-spacing: 0.01em;
    line-height: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}

.btn-accent:hover {
    background: linear-gradient(135deg, #be123c 0%, #e11d48 100%);
    color: white;
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.35);
    transform: translateY(-1px);
}

.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: #dc2626; color: white;}
.btn-success { background-color: var(--success); color: white; }
.btn-success:hover { background-color: #059669; color: white;}

/* Modern Ghost and Outline Buttons */
.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    box-shadow: none;
}
.btn-outline:hover {
    background-color: #f4f4f5;
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
    box-shadow: none;
    border: 1px solid transparent;
    padding: 8px 12px;
}
.btn-ghost:hover {
    background-color: #f4f4f5;
    color: var(--text-primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    position: relative;
}
.btn-icon:hover {
    background: #e4e4e7;
    color: var(--primary);
}

/* Forms */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 32px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: #f8fafc;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(10, 37, 64, 0.1);
}

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

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media(min-width: 768px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #1e3a8a 100%);
    position: relative;
    padding: 80px 0 100px;
    text-align: center;
    color: var(--surface);
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -50px; left: 0; right: 0;
    height: 100px;
    background: var(--bg-main);
    transform: skewY(-2deg);
}

.hero h1 {
    color: var(--surface);
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.hero p {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.8);
    max-width: 600px;
    margin: 0 auto;
}

/* Signature Pad */
.signature-wrapper {
    background: #f8fafc;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    transition: var(--transition);
}

.signature-wrapper:hover { border-color: var(--primary-light); }

.signature-pad {
    cursor: crosshair;
    width: 100%;
    height: 200px;
    background: transparent;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.bg-warning { background-color: #fef3c7; color: #b45309; }
.bg-success { background-color: #d1fae5; color: #047857; }
.bg-danger { background-color: #fee2e2; color: #b91c1c; }
.bg-primary { background-color: #e0e7ff; color: #4338ca; }

/* Premium Soft Badges */
.badge-soft {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.badge-soft-success { background: #d1fae5; color: #047857; }
.badge-soft-warning { background: #fef3c7; color: #b45309; }
.badge-soft-danger { background: #fee2e2; color: #b91c1c; }
.badge-soft-primary { background: #e0e7ff; color: #4338ca; }

/* Custom Tables (SaaS Look & Responsive Mobile Cards) */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.875rem;
    /* white-space: nowrap; Removed to prevent unwanted horizontal scrolling on laptops */
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    word-break: keep-all; 
}

th {
    background-color: #fafafa;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #f8fafc; }

/* Modal Detail Rows */
.detail-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
    width: 140px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    /* Transform tables into beautiful vertical cards */
    .table-responsive {
        border: none;
        box-shadow: none;
        background: transparent;
        overflow-x: hidden;
    }
    table {
        white-space: normal;
        background: transparent;
    }
    thead {
        display: none; /* Hide standard headers */
    }
    tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--surface);
        margin-bottom: 16px;
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        padding: 8px 0;
        transition: transform 0.2s, box-shadow 0.2s;
    }
    tbody tr:active { transform: scale(0.98); }
    tbody tr:hover td { background-color: transparent; }
    
    tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 20px;
        border-bottom: 1px solid rgba(226, 232, 240, 0.4);
        text-align: right;
        gap: 16px;
        font-size: 0.9rem;
    }
    tbody td:last-child { border-bottom: none; background: #fafafa; justify-content: flex-end; }
    
    /* Inject column headers dynamically as data-labels */
    tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.7rem;
        color: var(--text-muted);
        letter-spacing: 0.05em;
        flex-shrink: 0;
        text-align: left;
    }

    /* Modal responsiveness */
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .detail-label { width: 100%; font-size: 0.75rem; color: var(--text-muted); }
    
    .modal-profile-header {
        flex-direction: column;
        align-items: center !important;
        text-align: center;
    }
    .modal-profile-header img {
        margin-bottom: 15px;
    }
    .modal-profile-header .detail-row {
        align-items: center; /* Center rows since we centered the picture */
        text-align: center;
    }

    /* Global Paddings & UI tweaks */
    .app-content { padding: 16px !important; }
    .card { padding: 20px !important; }
    .stat-card-premium { padding: 20px; }
    div[style*="padding: 40px"] { padding: 24px !important; }
    
    /* Forms & Containers */
    .auth-form-container { padding: 24px !important; }
    .auth-form-container > div { padding: 15px !important; }
    .form-grid { grid-template-columns: 1fr; gap: 1rem; }

    /* Fix Topbar Modals & Profile Pill on mobile */
    #userInfoText, #userChevron { display: none !important; }
    #userProfilePill { padding: 2px !important; border-radius: 50% !important; }

    #notifDropdown {
        position: fixed !important;
        top: 70px !important;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        z-index: 9999 !important;
    }
    #userDropdown {
        position: fixed !important;
        top: 70px !important;
        right: 16px !important;
        width: 250px !important;
        z-index: 9999 !important;
    }
}

/* Authentication Pages */
.auth-wrapper {
    display: flex;
    min-height: 100vh;
}

.auth-split {
    flex: 1;
    display: none;
    background: linear-gradient(135deg, var(--primary), #1e3a8a);
    position: relative;
    overflow: hidden;
}

.auth-split::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('https://images.unsplash.com/photo-1497366216548-37526070297c?auto=format&fit=crop&q=80') center/cover;
    opacity: 0.2;
    mix-blend-mode: overlay;
}

.auth-sidebar-content {
    position: absolute;
    bottom: 10%;
    left: 10%;
    right: 10%;
    color: white;
}

.auth-form-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

@media(min-width: 992px) {
    .auth-split { display: block; }
    .auth-form-container { max-width: 600px; padding: 60px; }
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(10, 37, 64, 0.6);
    backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-content {
    background-color: var(--surface);
    border-radius: var(--radius-md);
    width: 100%; max-width: 800px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease-out;
}
.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: var(--surface); z-index: 10;
}
.modal-body { padding: 32px; }
.close-btn {
    font-size: 1.5rem; cursor: pointer; color: var(--text-muted);
    transition: var(--transition);
}
.close-btn:hover { color: var(--danger); transform: rotate(90deg); }

/* Sidebar Dashboard Layout */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-main);
}

.app-sidebar {
    width: 280px;
    background: linear-gradient(180deg, #0a192f 0%, #0f172a 100%); /* Deep modern blue gradient */
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: var(--transition);
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex; align-items: center; gap: 12px;
}

.sidebar-nav {
    padding: 24px 16px;
    flex: 1;
}

.sidebar-nav li {
    list-style: none;
    margin-bottom: 4px; /* Tighter layout */
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: #a1a1aa;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex; align-items: center; gap: 14px;
    border: 1px solid transparent;
}

.sidebar-nav li:hover {
    background: rgba(255,255,255,0.05);
    color: #f4f4f5;
}

.sidebar-nav li.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: none;
}

.sidebar-nav li.active i {
    color: var(--accent);
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
}

.app-topbar {
    height: 72px;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: flex-end; align-items: center;
    padding: 0 40px;
    z-index: 10;
    position: sticky;
    top: 0;
}

.app-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

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

.stat-card-premium {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card-premium.border-blue { border-left: 5px solid #3b82f6; }
.stat-card-premium.border-green { border-left: 5px solid #10b981; }
.stat-card-premium.border-yellow { border-left: 5px solid #f59e0b; }
.stat-card-premium.border-red { border-left: 5px solid #ef4444; }

.stat-card-premium:hover {
    box-shadow: var(--shadow-md); 
}

.stat-card-premium .stat-content {
    display: flex;
    flex-direction: column;
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Helper colors for icons */
.bg-primary-soft { background: #f4f4f5; }
.text-blue { color: #09090b; }
.bg-warning-soft { background: #fffbeb; }
.text-warning { color: #d97706; }
.bg-success-soft { background: #ecfdf5; }
.text-success { color: #059669; }
.bg-accent-soft { background: #fff1f2; }
.text-accent { color: #be123c; }

.stat-content p {
    margin: 0 0 4px 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-content h3 {
    margin: 0;
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

/* --- Mobile Responsiveness --- */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(9, 9, 11, 0.5);
    backdrop-filter: blur(4px);
    z-index: 15;
}

.sidebar-overlay.show { display: block; }

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 20;
        box-shadow: var(--shadow-xl);
    }
    .app-sidebar.show { left: 0; }
    
    .app-topbar {
        justify-content: flex-start;
        padding: 0 20px;
        gap: 16px;
    }
    .mobile-menu-btn { display: block; }
    
    .stat-grid {
        grid-template-columns: 1fr;
    }
    .app-content {
        padding: 20px;
    }
    .card {
        padding: 24px 20px;
    }
}
