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

:root {
    --primary:       #2563EB;
    --primary-dark:  #1D4ED8;
    --danger:        #DC2626;
    --success:       #16A34A;
    --warning:       #D97706;
    --bg:            #F8F9FB;
    --bg-card:       #FFFFFF;
    --border:        #E5E7EB;
    --text:          #111827;
    --text-muted:    #6B7280;
    --sidebar-w:     220px;
    --radius:        8px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* ─── Container ──────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-weight: 500; transition: .15s; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-outline { border: 1.5px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline:hover { background: #EFF6FF; text-decoration: none; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm  { padding: 5px 12px; font-size: 13px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger-outline  { border: 1.5px solid var(--danger); color: var(--danger); background: transparent; }
.btn-danger-outline:hover  { background: #FEF2F2; text-decoration: none; }
.btn-success-outline { border: 1.5px solid var(--success); color: var(--success); background: transparent; }
.btn-success-outline:hover { background: #F0FDF4; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-muted     { background: #F3F4F6; color: #374151; }
.badge-secondary { background: #F3F4F6; color: #6B7280; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; margin-bottom: 6px; }
.form-control { display: block; width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius); font: inherit; background: #fff; color: var(--text); transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.validation-message { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ─── Input with action icons (show/copy) ────────────────────────────────── */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .form-control { flex: 1; padding-right: 74px; }
.input-wrap.single-action .form-control { padding-right: 40px; }
.input-icon-btn {
    position: absolute; right: 0; top: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    width: 36px; background: transparent; border: none; cursor: pointer;
    color: #9ca3af; border-radius: 0 var(--radius) var(--radius) 0;
    transition: color .15s, background .15s;
}
.input-icon-btn:hover { color: var(--text); background: rgba(0,0,0,.04); }
.input-icon-btn:active { background: rgba(0,0,0,.08); }
.input-icon-btn + .input-icon-btn { right: 36px; border-radius: 0; }
.input-icon-btn svg { pointer-events: none; flex-shrink: 0; }
.input-copy-toast {
    position: absolute; right: 0; top: -28px;
    background: #1e293b; color: #fff; font-size: 11px;
    padding: 3px 8px; border-radius: 4px; white-space: nowrap;
    animation: fadeInUp .15s ease, fadeOut .2s ease .9s forwards;
    pointer-events: none; z-index: 10;
}
@keyframes fadeInUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeOut  { from { opacity:1; } to { opacity:0; } }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 1.5px solid var(--border); white-space: nowrap; }
td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #F9FAFB; }

/* ─── Alert ──────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ─── Public Layout ──────────────────────────────────────────────────────── */
.public-layout { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.public-header .container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.public-header .logo { font-weight: 700; font-size: 18px; color: var(--primary); }
.public-nav { display: flex; align-items: center; gap: 16px; }
.public-nav .nav-link { color: var(--text); font-weight: 500; }
.public-main { flex: 1; }
.public-footer { background: #fff; border-top: 1px solid var(--border); padding: 16px 0; }
.public-footer .container { display: flex; align-items: center; justify-content: space-between; }
.lang-switch { font-size: 13px; color: var(--text-muted); }

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero { padding: 80px 0; text-align: center; background: linear-gradient(135deg, #EFF6FF 0%, #F8F9FB 100%); }
.hero-title { font-size: 42px; font-weight: 700; color: var(--text); line-height: 1.15; margin-bottom: 16px; }
.hero-subtitle { font-size: 18px; color: var(--text-muted); margin-bottom: 32px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; justify-content: center; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; padding: 64px 24px; }
.feature-card { background: #fff; border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.feature-icon { font-size: 28px; margin-bottom: 12px; }
.feature-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

/* ─── App Layout (Cabinet / Admin) ──────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #1E293B; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo a { font-weight: 700; font-size: 16px; color: #fff; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-bottom { padding: 8px 8px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; color: rgba(255,255,255,.65); font-size: 13.5px; font-weight: 500; transition: .15s; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(37,99,235,.35); color: #fff; }
.logout-btn { width: 100%; text-align: left; color: rgba(255,255,255,.65); font-size: 13.5px; font-weight: 500; }
.logout-btn:hover { color: #fff; }
.sidebar-admin .nav-item.active { background: rgba(220,38,38,.3); }
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.admin-badge { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--danger); }
.page-content { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ─── Page header ─────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ─── Validation ─────────────────────────────────────────────────────────── */
.validation-message { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }

/* ─── Auth pages ─────────────────────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 60px - 53px); padding: 40px 0; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow); }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; text-align: center; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }

/* ─── Spinner ─────────────────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1E293B; color: #fff; padding: 12px 18px; border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.15); font-size: 13px; animation: toast-in .25s ease; }
.toast.toast-success { background: #166534; }
.toast.toast-error   { background: #991B1B; }
@keyframes toast-in { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

/* ─── Language switcher ───────────────────────────────────────────────────── */
.lang-switch { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.lang-switch a { color: var(--text-muted); }
.lang-switch a:hover { color: var(--primary); text-decoration: none; }
.lang-switch a.lang-active { color: var(--primary); font-weight: 600; }

/* ─── Hamburger (mobile only) ─────────────────────────────────────────────── */
.hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 36px; height: 36px; padding: 4px; border-radius: 6px; background: none; border: none; cursor: pointer; }
.hamburger span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }
.hamburger:hover { background: var(--border); }

/* ─── Sidebar overlay (mobile) ───────────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Hamburger visible */
    .hamburger { display: flex; }

    /* Sidebar hidden by default on mobile, slides in when .sidebar-open */
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
        transform: translateX(-100%);
        transition: transform .25s ease;
        width: 240px;
    }
    .app-layout.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .app-layout.sidebar-open .sidebar-overlay {
        display: block;
    }

    /* Content fills full width */
    .main-content { width: 100%; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }

    /* Tables scroll horizontally */
    .card table { min-width: 500px; }
    .card { overflow-x: auto; padding: 16px; }

    /* Page header stacks on small screens */
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header > div:last-child { width: 100%; }
    .page-header .btn { width: 100%; justify-content: center; }

    /* Auth card */
    .auth-card { padding: 24px 20px; }

    /* Hero */
    .hero { padding: 48px 0; }
    .hero-title { font-size: 28px; }
    .hero-subtitle { font-size: 16px; }
    .hero-actions { flex-direction: column; align-items: center; }
    .features { grid-template-columns: 1fr; padding: 32px 16px; }

    /* Public header nav */
    .public-nav { gap: 8px; }
    .public-nav .nav-link { display: none; }

    /* Stats grid single column */
    .stats-grid { grid-template-columns: 1fr !important; }

    /* Topbar email hidden on very small screens */
    .user-email { display: none; }
}

@media (max-width: 480px) {
    .btn-lg { padding: 10px 18px; font-size: 14px; }
    .page-title { font-size: 18px; }
}
