/* ================================================================
   ARG Client Portal — Base Styles & Design System
   Modern, clean aesthetic with generous whitespace
   ================================================================ */

:root {
    /* Colors — Refined green palette */
    --green-50: #e8f5f3;
    --green-100: #c6ece7;
    --green-200: #a0d5cf;
    --green-500: #2BA396;
    --green-600: #1A8A7D;
    --green-700: #15756B;
    --green-800: #0D5C53;
    --green-900: #0A4A42;

    --gray-25: #fcfcfd;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --amber-50: #fffbeb;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --blue-50: #eff6ff;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;

    /* Semantic */
    --primary: var(--green-600);
    --primary-hover: var(--green-700);
    --primary-light: var(--green-50);
    --danger: var(--red-500);
    --danger-hover: var(--red-600);
    --warning: var(--amber-500);
    --info: var(--blue-500);
    --text: var(--gray-800);
    --text-secondary: var(--gray-500);
    --text-muted: var(--gray-400);
    --bg: #ffffff;
    --bg-page: var(--gray-50);
    --border: var(--gray-200);
    --border-light: var(--gray-100);

    /* Typography */
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.06), 0 8px 10px -6px rgba(0,0,0,0.04);

    /* Layout */
    --sidebar-w: 260px;
    --topbar-h: 64px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); color: var(--text); background: var(--bg-page); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ── Typography ─────────────────────────────────────────── */
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; color: var(--gray-900); }
h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; color: var(--gray-900); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-weight: 600; font-size: 0.9rem; cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-danger { background: var(--red-50); color: var(--red-600); border: 1px solid transparent; }
.btn-danger:hover { background: var(--red-500); color: #fff; }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-xs { padding: 4px 10px; font-size: 0.78rem; border-radius: var(--radius-sm); }

.btn-icon {
    width: 36px; height: 36px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block; margin-bottom: 6px;
    font-weight: 500; font-size: 0.88rem; color: var(--gray-700);
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { margin-top: 6px; font-size: 0.8rem; color: var(--text-muted); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.card-header h2 { margin: 0; }
.card-body { padding: 24px; }
.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 10px 16px; text-align: left;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 14px 16px; border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem; color: var(--text);
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--gray-25); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Status Badges ──────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}
.badge-open { background: var(--green-100); color: var(--green-800); }
.badge-in_progress, .badge-in-progress { background: var(--blue-50); color: var(--blue-600); }
.badge-on_hold, .badge-on-hold { background: var(--amber-50); color: var(--amber-600); }
.badge-closed { background: var(--gray-100); color: var(--gray-600); }
.badge-done { background: var(--green-100); color: var(--green-700); }
.badge-pending { background: var(--gray-100); color: var(--gray-500); }
.badge-cancelled { background: var(--red-50); color: var(--red-600); }
.badge-admin { background: var(--gray-800); color: #fff; }
.badge-client { background: var(--green-100); color: var(--green-700); }

/* ── Flash Messages ─────────────────────────────────────── */
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; border-radius: var(--radius);
    margin-bottom: 20px; font-size: 0.9rem; font-weight: 500;
    animation: flashIn 0.25s ease-out;
}
.flash-close { background: none; border: none; cursor: pointer; margin-left: auto; font-size: 1.2rem; opacity: 0.5; color: inherit; }
.flash-close:hover { opacity: 1; }
.flash-success { background: var(--green-50); color: var(--green-800); border: 1px solid var(--green-200); }
.flash-error { background: var(--red-50); color: var(--red-600); border: 1px solid #fecaca; }
.flash-warning { background: var(--amber-50); color: var(--amber-600); border: 1px solid #fde68a; }
.flash-info { background: var(--blue-50); color: var(--blue-600); border: 1px solid #bfdbfe; }

@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; gap: 4px;
    justify-content: center; padding: 16px 0;
}
.pg-btn, .pg-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 12px;
    border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); text-decoration: none;
    transition: all 0.15s;
}
.pg-btn:hover, .pg-num:hover { background: var(--gray-100); color: var(--text); text-decoration: none; }
.pg-num.active { background: var(--primary); color: #fff; }
.pg-btn.disabled { opacity: 0.4; pointer-events: none; }
.pg-dots { color: var(--text-muted); padding: 0 4px; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); width: 90%; max-width: 560px; max-height: 90vh;
    overflow-y: auto; transform: translateY(10px); transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { font-size: 1.15rem; }
.modal-close {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: none; background: var(--gray-100); border-radius: 50%; cursor: pointer;
    color: var(--text-secondary); transition: all 0.15s;
}
.modal-close:hover { background: var(--gray-200); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Search ─────────────────────────────────────────────── */
.search-box {
    position: relative; max-width: 300px;
}
.search-box .form-input { padding-left: 38px; }
.search-box::before {
    content: '';
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-size: contain;
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* ── Auth Pages ─────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(160deg, #F8FAFB 0%, #fff 50%, #e8f5f3 100%);
}
.auth-header { text-align: center; margin-bottom: 40px; }
.auth-header .logo { display: flex; align-items: center; gap: 14px; justify-content: center; }
.auth-header h1 { font-size: 1.5rem; color: #1B2A3D; margin: 0; }
.auth-header p { color: var(--text-secondary); font-size: 0.9rem; margin: 0; }

.logo-mark {
    width: 44px; height: 44px;
    background: #1A8A7D;
    color: #fff; font-weight: 700; font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    letter-spacing: 0.04em;
}

.auth-body { width: 100%; max-width: 420px; }
.auth-card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 36px;
}
.auth-card h2 { text-align: center; margin-bottom: 8px; }
.auth-card .subtitle { text-align: center; color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 28px; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 0.95rem; margin-top: 4px; }
.auth-links { text-align: center; margin-top: 20px; font-size: 0.88rem; color: var(--text-secondary); }
.auth-links a { font-weight: 500; }

.auth-footer { margin-top: 40px; text-align: center; color: var(--text-muted); font-size: 0.8rem; }

/* ── Utilities ──────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.78rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .auth-card { padding: 28px 24px; }
    .hide-mobile { display: none !important; }
}

/* ── Checkbox ───────────────────────────────────────────── */
.checkbox-label {
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 0.88rem; color: var(--text); cursor: pointer;
    line-height: 1.5;
}
.checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px; margin-top: 2px;
    accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
}
.checkbox-label a { font-weight: 500; }

/* ── Legal Content ──────────────────────────────────────── */
.legal-content {
    margin-top: 24px; font-size: 0.88rem; line-height: 1.75;
    color: var(--gray-700); max-height: 60vh; overflow-y: auto;
    padding-right: 8px;
}
.legal-content h3 {
    margin-top: 24px; margin-bottom: 8px;
    font-size: 0.95rem; font-weight: 700; color: var(--gray-900);
}
.legal-content p { margin-bottom: 12px; }
.legal-content::-webkit-scrollbar { width: 5px; }
.legal-content::-webkit-scrollbar-track { background: var(--gray-100); border-radius: 10px; }
.legal-content::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }

/* ── Org Role Badges ────────────────────────────────────── */
.badge-owner { background: #fef3c7; color: #92400e; }
.badge-manager { background: var(--blue-50); color: var(--blue-600); }
.badge-member { background: var(--gray-100); color: var(--gray-600); }
.badge-viewer { background: var(--gray-100); color: var(--gray-400); }
