/* MailEngine - Main Styles */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #818CF8;
    --secondary: #0EA5E9;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --dark: #1E293B;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a.btn { color: inherit; }
a.btn-primary { color: #fff; }
a:hover { color: var(--primary-dark); }

/* ========== LOGIN PAGE ========== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.login-logo .logo-icon svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.login-logo p {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    background: #fff;
    color: var(--gray-800);
    transition: all 0.2s;
    outline: none;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.input-icon-wrapper .form-control {
    padding-left: 42px;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.password-toggle:hover {
    color: var(--gray-600);
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.5;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    padding: 12px 20px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }

/* ========== ALERTS ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-danger {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-success {
    background: #F0FDF4;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border: 1px solid #FDE68A;
}

/* ========== SIDEBAR LAYOUT ========== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .s-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-header .s-logo svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--gray-400);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.nav-link.active {
    background: rgba(79, 70, 229, 0.2);
    color: var(--primary-light);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-link .badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* Sidebar dropdown */
.nav-dropdown .nav-sub {
    margin-top: 4px;
    padding: 6px;
    background: rgba(0,0,0,0.25);
    border-radius: 8px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
    padding-top: 0;
    padding-bottom: 0;
}
.nav-dropdown.open .nav-sub {
    max-height: 200px;
    opacity: 1;
    padding-top: 6px;
    padding-bottom: 6px;
}
.nav-dropdown.open .dropdown-arrow { transform: rotate(180deg); }
.nav-sublink {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--gray-400);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s;
    text-decoration: none;
    margin-bottom: 2px;
}
.nav-sublink:hover {
    background: rgba(79, 70, 229, 0.2);
    color: #fff;
}
.nav-sublink svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.06);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; color: #fff; }
.user-info .email { font-size: 12px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 32px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-content {
    padding: 32px;
}

/* ========== STAT CARDS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--gray-200);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.stat-card .stat-icon.blue { background: rgba(79,70,229,0.15); color: var(--primary); }
.stat-card .stat-icon.green { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-card .stat-icon.yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-card .stat-icon.red { background: rgba(239,68,68,0.15); color: var(--danger); }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -1px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
    font-weight: 500;
}

/* Colorful gradient stat cards (Dashboard) */
.stat-card[class*="bg-"] {
    border-radius: 16px;
    border: none;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card[class*="bg-"]::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    pointer-events: none;
}
.stat-card[class*="bg-"]::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: -10%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
}
.stat-card[class*="bg-"]:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}
.stat-card.bg-indigo { background: linear-gradient(135deg, #6366F1, #4F46E5, #4338CA); }
.stat-card.bg-emerald { background: linear-gradient(135deg, #34D399, #10B981, #059669); }
.stat-card.bg-amber { background: linear-gradient(135deg, #FBBF24, #F59E0B, #D97706); }
.stat-card.bg-rose { background: linear-gradient(135deg, #FB7185, #F43F5E, #E11D48); }
.stat-card.bg-cyan { background: linear-gradient(135deg, #22D3EE, #06B6D4, #0891B2); }
.stat-card.bg-violet { background: linear-gradient(135deg, #A78BFA, #8B5CF6, #7C3AED); }

.stat-card[class*="bg-"] .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.stat-card[class*="bg-"] .stat-value {
    font-size: 32px;
    color: #fff;
    line-height: 1;
}
.stat-card[class*="bg-"] .stat-label {
    color: rgba(255,255,255,0.8);
    letter-spacing: 0.3px;
    margin-top: 6px;
}

/* ========== CARDS ========== */
.card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.card-body {
    padding: 24px;
}

/* ========== TABLE ========== */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

table tr:hover td {
    background: var(--gray-50);
}

/* ========== STATUS BADGES ========== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active { background: #F0FDF4; color: #166534; }
.badge-inactive { background: #FEF2F2; color: #991B1B; }
.badge-pending { background: #FFFBEB; color: #92400E; }

.badge-active::before,
.badge-inactive::before,
.badge-pending::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-active::before { background: #22C55E; }
.badge-inactive::before { background: #EF4444; }
.badge-pending::before { background: #F59E0B; }

/* ========== CHECKBOX REMEMBER ME ========== */
.form-check {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.form-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-check a {
    font-size: 13px;
    font-weight: 500;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 20px;
    }

    .login-card {
        padding: 32px 24px;
    }
}

/* ========== TOGGLE SWITCH ========== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 20px;
    transition: 0.25s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--success, #10b981); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
