/* ============================================
   Reseller Portal - Stylesheet
   ============================================ */

:root {
    --bg:        #f5f7fb;
    --surface:   #ffffff;
    --border:    #e5e9f0;
    --text:      #1a2238;
    --text-muted:#6b7280;
    --primary:   #4f46e5;
    --primary-d: #4338ca;
    --success:   #10b981;
    --warn:      #f59e0b;
    --danger:    #ef4444;
    --shadow:    0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
    --shadow-md: 0 4px 12px rgba(16,24,40,.08);
    --radius:    10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, 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; }

h1, h2, h3 { margin: 0 0 8px 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

.muted { color: var(--text-muted); }

/* ============ TOPBAR ============ */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 16px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
}
.brand-dot-lg { width: 32px; height: 32px; margin: 0 auto 12px; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
    padding: 8px 14px; border-radius: 8px; color: var(--text-muted);
    font-weight: 500; position: relative;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--bg); color: var(--primary); }
.nav a.logout { color: var(--danger); }
.badge-dot {
    display: inline-block; width: 6px; height: 6px;
    background: var(--warn); border-radius: 50%;
    margin-left: 4px; vertical-align: middle;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ============ LAYOUT ============ */
.container {
    max-width: 1200px; margin: 0 auto;
    padding: 28px 24px;
}
.footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 16px 0; margin-top: 40px;
    color: var(--text-muted); font-size: 13px;
}
.footer .container { padding: 0 24px; }

/* ============ PAGE HEAD ============ */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ STATS ============ */
.stats {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-value.mode-normal { color: var(--text); }
.stat-value.mode-todo   { color: var(--warn); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; justify-content: center; padding: 11px 16px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost     { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warn      { background: var(--warn); color: #fff; }
.btn-warn:hover { background: #d97706; }

.btn-sm {
    display: inline-block;
    padding: 5px 10px;
    font-size: 12px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer;
}
.btn-sm:hover { background: var(--surface); text-decoration: none; }
.btn-sm-danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-sm-danger:hover { background: #fee2e2; }

/* ============ TABLES ============ */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table .num     { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions { white-space: nowrap; text-align: right; }
.data-table .actions form { margin-left: 4px; }

/* ============ STATUS / RENEWAL ============ */
.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 500;
}
.status-pending   { background: #f3f4f6; color: #4b5563; }
.status-given     { background: #d1fae5; color: #065f46; }
.status-not_given { background: #fee2e2; color: #991b1b; }

.renewal {
    display: inline-block;
    font-size: 13px;
}
.renewal.overdue  { color: var(--danger); font-weight: 600; }
.renewal.soon     { color: var(--warn);   font-weight: 600; }
.renewal.upcoming { color: var(--text); }

/* ============ FORMS ============ */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 560px;
    box-shadow: var(--shadow);
}
.field {
    display: block;
    margin-bottom: 16px;
}
.field > span {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 13px;
}
.field input[type=text],
.field input[type=number],
.field input[type=password],
.field input[type=date],
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.field small { display: block; margin-top: 4px; font-size: 12px; }
.form-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 20px; padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ============ ALERTS ============ */
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error    { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warn     { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert code     { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; }

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ============ EMPTY STATE ============ */
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}
.empty-state h3 { margin-bottom: 8px; }
.empty-state p  { color: var(--text-muted); margin-bottom: 16px; }

/* ============ AUTH PAGES ============ */
.auth-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f7fb 100%);
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 { margin: 8px 0 4px; font-size: 20px; }
.auth-header p  { margin: 0; }

.setup-list { padding-left: 0; list-style: none; margin: 0 0 16px; font-size: 14px; }
.setup-list li { padding: 6px 0; }

/* ============ TODO LIST ============ */
.progress-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.progress-stats {
    display: flex; flex-wrap: wrap; gap: 18px;
    font-size: 13px; margin-bottom: 12px;
}
.progress-stats > div { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-pending  { background: #d1d5db; }
.dot-given    { background: var(--success); }
.dot-notgiven { background: var(--danger); }
.progress-bar {
    height: 8px;
    background: #f3f4f6;
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.todo-list {
    display: flex; flex-direction: column; gap: 8px;
}
.todo-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid #d1d5db;
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}
.todo-item.todo-given     { border-left-color: var(--success); background: #f6fefa; }
.todo-item.todo-not_given { border-left-color: var(--danger);  background: #fef9f9; }
.todo-item.todo-given .todo-name,
.todo-item.todo-not_given .todo-name { opacity: 0.75; }

.todo-main { flex: 1; min-width: 200px; }
.todo-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.todo-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-chip {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 999px;
    background: #f3f4f6; color: #4b5563;
    font-size: 12px;
}
.meta-chip.muted { color: var(--text-muted); background: #f9fafb; }
.meta-chip.renewal.overdue { background: #fee2e2; color: #991b1b; }
.meta-chip.renewal.soon    { background: #fef3c7; color: #92400e; }

.todo-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-todo {
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-todo:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-todo:not(:disabled):hover { background: var(--bg); }
.btn-todo.btn-given.is-active     { background: var(--success); color: #fff; border-color: var(--success); }
.btn-todo.btn-notgiven.is-active  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-todo.btn-reset-one.is-active { background: #6b7280; color: #fff; border-color: #6b7280; }
.btn-reset-one { padding: 8px 10px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
    .container { padding: 16px; }
    .topbar-inner { padding: 12px 16px; }
    .nav a { padding: 6px 10px; font-size: 13px; }
    .data-table thead { display: none; }
    .data-table tbody td {
        display: block;
        padding: 6px 16px;
        border: none;
    }
    .data-table tbody tr {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }
    .data-table .num, .data-table .actions { text-align: left; }
    .todo-item { flex-direction: column; align-items: flex-start; }
    .todo-actions { width: 100%; }
    .btn-todo { flex: 1; text-align: center; justify-content: center; display: flex; }
}
