/* ============================================================================
   Datalumeno — Application Stylesheet
   Light, friendly, boxed layout with top navigation
   ============================================================================ */

:root {
    /* ── Brand ─────────────────────────────── */
    --primary:       #0ea5e9;
    --primary-dark:  #0284c7;
    --primary-light: #38bdf8;
    --primary-glow:  rgba(14, 165, 233, 0.12);
    --accent:        #f83b54;

    /* ── Surfaces ──────────────────────────── */
    --bg-base:       #f5f7fa;
    --bg-surface:    #ffffff;
    --bg-card:       #ffffff;
    --bg-card-hover: #fafbfc;

    /* ── Borders ───────────────────────────── */
    --border:        #e8ecf1;
    --border-strong: #d1d9e0;

    /* ── Text ──────────────────────────────── */
    --text-primary:  #1e293b;
    --text-muted:    #64748b;
    --text-dim:      #94a3b8;

    /* ── Semantic ──────────────────────────── */
    --success:       #10b981;
    --success-bg:    #ecfdf5;
    --warning:       #f59e0b;
    --warning-bg:    #fffbeb;
    --danger:        #ef4444;
    --danger-bg:     #fef2f2;
    --info:          #3b82f6;
    --info-bg:       #eff6ff;

    /* ── Gray scale ────────────────────────── */
    --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;

    /* ── Layout ────────────────────────────── */
    --radius:        12px;
    --radius-sm:     8px;
    --radius-xs:     6px;
    --topnav-height: 58px;
    --layout-max:    1140px;
    --shadow:        0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* ══════════════════════════════════════════════
   TOP NAVIGATION
   ══════════════════════════════════════════════ */

.topnav {
    height: var(--topnav-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.topnav-inner {
    max-width: var(--layout-max);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Logo ──────────────────────────────── */
.topnav-logo {
    text-decoration: none !important;
    display: flex;
    align-items: center;
    margin-right: 24px;
    flex-shrink: 0;
}
.topnav-logo:hover { text-decoration: none; }

.logo-wordmark {
    display: flex;
    flex-direction: column;
    line-height: 1;
}
.logo-line1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.logo-line2 {
    font-size: 8.5px;
    color: var(--text-dim);
    text-align: right;
    margin-top: 2px;
    letter-spacing: 0.02em;
}
.l-marketbox {
    font-weight: 700;
    color: var(--text-muted);
}
.l-box {
    color: #f83b54;
    font-weight: 700;
}

/* ── Nav links ─────────────────────────── */
.topnav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}
.tnav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-xs);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.tnav-link:hover {
    color: var(--text-primary);
    background: var(--gray-100);
}
.tnav-link.active {
    color: var(--primary);
    background: var(--primary-glow);
    font-weight: 600;
}
.tnav-link .nav-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

/* ── Nav right ─────────────────────────── */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.topnav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.topnav-user:hover { background: var(--gray-100); }
.topnav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}
.topnav-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.topnav-credits {
    font-size: 11px;
    color: var(--text-dim);
}

.notif-bell {
    position: relative;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-xs);
    transition: all 0.15s;
}
.notif-bell:hover { color: var(--text-primary); background: var(--gray-100); }
.notif-count {
    position: absolute;
    top: 0;
    right: -2px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    line-height: 1.3;
}

/* ── Hamburger ─────────────────────────── */
.tnav-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    padding: 6px;
    cursor: pointer;
    border-radius: var(--radius-xs);
}
.tnav-hamburger:hover { background: var(--gray-100); }

/* ══════════════════════════════════════════════
   MAIN LAYOUT (boxed)
   ══════════════════════════════════════════════ */

.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    max-width: var(--layout-max);
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
}

.site-footer {
    max-width: var(--layout-max);
    width: 100%;
    margin: 0 auto;
    padding: 20px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}
.site-footer a { color: var(--text-muted); }

/* ══════════════════════════════════════════════
   GUEST LAYOUT (login/register)
   ══════════════════════════════════════════════ */

.guest-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
}
.guest-container { width: 100%; max-width: 420px; padding: 20px; }
.guest-brand { text-align: center; margin-bottom: 32px; }
.guest-brand .logo-wordmark { display: inline-flex; flex-direction: column; line-height: 1; }
.guest-brand .logo-line1 { font-size: 28px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.guest-brand .logo-line2 { font-size: 11px; color: var(--text-dim); text-align: right; margin-top: 3px; }
.guest-brand p { color: var(--text-dim); font-size: 0.95em; margin-top: 8px; }
.guest-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.guest-card h2 { margin-bottom: 20px; font-size: 1.2em; font-weight: 600; }
.guest-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.8em;
    color: var(--text-dim);
}

/* ══════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════ */

/* ── Buttons ───────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-full { width: 100%; text-align: center; }
.btn-icon { padding: 6px 8px; }

/* ── Forms ─────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-primary);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color 0.15s, box-shadow 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-glow);
}
.form-footer { text-align: center; margin-top: 15px; font-size: 13px; color: var(--text-muted); }
.form-footer a { color: var(--primary); font-weight: 500; }

/* ── Alerts ────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid transparent;
}
.alert-error   { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--info-bg); color: #1e40af; border-color: #bfdbfe; }

/* ── Cards ─────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.card-link { display: block; text-decoration: none; color: inherit; transition: all 0.2s; }
.card-link:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1em; font-weight: 600; }
.card-meta { display: flex; gap: 15px; font-size: 12px; color: var(--text-dim); margin-top: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── Badges ────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-error   { background: var(--danger-bg); color: #991b1b; }
.badge-info    { background: var(--info-bg); color: #1e40af; }
.badge-warning { background: var(--warning-bg); color: #92400e; }

/* ── Stats ─────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
}
.stat-value { font-size: 2em; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--text-dim); }

/* ── Progress ──────────────────────────── */
.progress-bar {
    background: var(--gray-200);
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
    margin: 10px 0 5px;
}
.progress-fill {
    background: linear-gradient(90deg, var(--primary), var(--success));
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
}
.progress-label { font-size: 12px; color: var(--text-muted); text-align: right; }

/* ── Sections ──────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 28px 0 16px;
}
.section-header h2 { font-size: 1.15em; font-weight: 600; }

/* ── Tables ────────────────────────────── */
.table-container { overflow-x: auto; border-radius: var(--radius); }
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
th {
    background: var(--gray-50);
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
tr:hover { background: var(--gray-50); }

/* ── Content area ─────────────────────── */
.content-area { }

/* ── Error page ───────────────────────── */
.error-page {
    text-align: center;
    padding: 80px 20px;
}
.error-page h1 {
    font-size: 4em;
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.error-page p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ── Utilities ─────────────────────────── */
.text-muted { color: var(--text-muted) !important; font-size: 0.85em; }
.text-dim { color: var(--text-dim); }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty-state p { margin-bottom: 15px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

/* ── Toast ─────────────────────────────── */
#toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {
    .topnav-links { display: none; }
    .tnav-hamburger { display: block; }
    .topnav-username { display: none; }

    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card-grid { grid-template-columns: 1fr; }

    .mobile-nav {
        display: flex;
        flex-direction: column;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        max-width: var(--layout-max);
        margin: 0 auto;
        padding: 8px 16px;
    }
    .mobile-nav .tnav-link {
        padding: 10px 16px;
        border-radius: var(--radius-sm);
        width: 100%;
    }
    .mobile-nav .nav-divider {
        border: none;
        border-top: 1px solid var(--border);
        margin: 6px 0;
    }
}

@media (min-width: 769px) {
    .mobile-nav { display: none !important; }
}
