/* ============================================
   GSRP Bot – Shared Design System
   Modern Dark Theme
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Background layers */
    --bg-base: #0a0d12;
    --bg-surface: #111419;
    --bg-raised: #181c24;
    --bg-overlay: #1f2430;
    --bg-hover: #262d3b;
    --bg-input: #0d1016;

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-strong: rgba(255, 255, 255, 0.1);
    --border-focus: #6c63ff;

    /* Text */
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-heading: #f1f5f9;

    /* Accent – Indigo/Violet */
    --accent: #6c63ff;
    --accent-hover: #8b83ff;
    --accent-muted: rgba(108, 99, 255, 0.12);
    --accent-glow: rgba(108, 99, 255, 0.25);

    /* Semantic colors */
    --green: #22d3a7;
    --green-muted: rgba(34, 211, 167, 0.1);
    --red: #f87171;
    --red-muted: rgba(248, 113, 113, 0.1);
    --yellow: #f59e0b;
    --yellow-muted: rgba(245, 158, 11, 0.1);
    --purple: #a78bfa;
    --purple-muted: rgba(167, 139, 250, 0.1);
    --cyan: #22d3ee;
    --cyan-muted: rgba(34, 211, 238, 0.1);

    /* Radius */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 24px 56px rgba(0,0,0,0.6);

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 200ms;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle grid-dot background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.012) 1px, transparent 0);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* Ambient glow – dual color */
body::after {
    content: '';
    position: fixed;
    top: -300px;
    left: 50%;
    transform: translateX(-50%);
    width: 1200px;
    height: 600px;
    background:
        radial-gradient(ellipse at 35% 50%, rgba(108, 99, 255, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 65% 50%, rgba(34, 211, 238, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.14);
}

/* ============================================
   Navigation
   ============================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 13, 18, 0.75);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.brand-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.3px;
}

.brand-badge {
    padding: 2px 8px;
    background: var(--accent-muted);
    border: 1px solid rgba(91, 141, 239, 0.15);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* Auth-protected nav links: hidden until JS shows them after login */
.nav-link[data-auth="required"] {
    display: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.nav-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg-overlay);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-muted);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
    line-height: 1;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b83ff);
    color: #fff;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #a09aff);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--green), #2ee8b8);
    color: #0a0d12;
    box-shadow: 0 2px 8px rgba(34, 211, 167, 0.3);
}
.btn-success:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(34, 211, 167, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
    color: var(--text);
    background: var(--bg-overlay);
    border-color: rgba(255,255,255,0.15);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.25);
}
.btn-danger-ghost:hover {
    background: var(--red-muted);
    border-color: var(--red);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--duration) var(--ease);
}
.btn-icon:hover {
    color: var(--text);
    background: var(--bg-overlay);
    border-color: rgba(255,255,255,0.15);
}
.btn-icon svg { width: 16px; height: 16px; }

/* Login / Logout in nav */
.btn-login {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-muted);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--duration) var(--ease);
}
.btn-login:hover {
    background: rgba(108, 99, 255, 0.2);
    border-color: var(--accent);
}
.btn-login svg { width: 16px; height: 16px; }

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--red-muted);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--duration) var(--ease);
}
.btn-logout:hover {
    background: rgba(248, 113, 113, 0.18);
    border-color: var(--red);
}
.btn-logout svg { width: 16px; height: 16px; }

/* ============================================
   Layout
   ============================================ */
.wrapper, .container-main {
    max-width: 100%;
    margin: 0 auto;
    padding: 32px 40px;
    position: relative;
    z-index: 1;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    line-height: 1.2;
}

.page-description {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 400;
}

/* ============================================
   Sections
   ============================================ */
.section-header {
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.section-description {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 0 20px rgba(108, 99, 255, 0.06);
}

/* ============================================
   Forms
   ============================================ */
.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.label-hint {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

input[type="text"],
input[type="password"],
input[type="time"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

select:disabled, input:disabled, textarea:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.char-counter {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease);
}
.checkbox-label:hover {
    border-color: var(--border-focus);
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}
.checkbox-label span { flex: 1; font-size: 13px; }
.checkbox-hint { display: block; margin-top: 3px; }

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    background: var(--bg-raised);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

td {
    color: var(--text-secondary);
    font-size: 13px;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background var(--duration) var(--ease);
}
tbody tr:hover {
    background: var(--bg-raised);
}

.actions-column {
    width: 120px;
    text-align: center;
}

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
    justify-content: center;
}

/* ============================================
   Action Buttons (Table)
   ============================================ */
.toggle-btn, .edit-btn, .delete-btn {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--duration) var(--ease);
    border: 1px solid;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.toggle-btn {
    color: var(--accent);
    border-color: rgba(108, 99, 255, 0.25);
    background: transparent;
}
.toggle-btn:hover {
    background: var(--accent-muted);
    border-color: var(--accent);
}

.edit-btn {
    color: var(--yellow);
    border-color: rgba(245, 158, 11, 0.25);
    background: transparent;
}
.edit-btn:hover {
    background: var(--yellow-muted);
    border-color: var(--yellow);
}

.delete-btn {
    color: var(--red);
    border-color: rgba(248, 113, 113, 0.25);
    background: transparent;
}
.delete-btn:hover {
    background: var(--red-muted);
    border-color: var(--red);
}

/* ============================================
   Status Badges
   ============================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border: 1px solid;
}

.status-badge.active {
    color: var(--green);
    background: var(--green-muted);
    border-color: rgba(34, 211, 167, 0.25);
}

.status-badge.inactive {
    color: var(--yellow);
    background: var(--yellow-muted);
    border-color: rgba(245, 158, 11, 0.25);
}

.inactive-row { opacity: 0.5; }
.inactive-row:hover { opacity: 0.75; }

/* ============================================
   No-Data Empty State
   ============================================ */
.no-data {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}

.no-data svg {
    opacity: 0.25;
    margin-bottom: 16px;
}

.no-data p {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.no-data span {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================
   Notifications / Toast
   ============================================ */
.notification {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    transition: top 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 460px;
    text-align: center;
    border: 1px solid;
    backdrop-filter: blur(12px);
}

.notification.show { top: 20px; }

.notification.success, .notification-success {
    background: rgba(10, 13, 18, 0.92);
    color: var(--green);
    border-color: rgba(34, 211, 167, 0.3);
}
.notification.error, .notification-error {
    background: rgba(10, 13, 18, 0.92);
    color: var(--red);
    border-color: rgba(248, 113, 113, 0.3);
}
.notification.warning, .notification-warning {
    background: rgba(10, 13, 18, 0.92);
    color: var(--yellow);
    border-color: rgba(245, 158, 11, 0.3);
}
.notification-info {
    background: rgba(10, 13, 18, 0.92);
    color: var(--accent);
    border-color: rgba(108, 99, 255, 0.3);
}

/* ============================================
   Loading Spinner
   ============================================ */
.loader {
    position: fixed;
    inset: 0;
    background: rgba(10, 13, 18, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
    backdrop-filter: blur(4px);
}
.loader.show { display: flex; }

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   Modals
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from { transform: translateY(24px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-heading);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease);
}
.modal-close:hover {
    background: var(--bg-overlay);
    color: var(--text);
}

.modal-body { padding: 24px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group:last-child { margin-bottom: 0; }

.modal-hint {
    margin-top: 16px;
    padding: 12px;
    background: var(--yellow-muted);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--yellow);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ============================================
   Password / Login Container
   ============================================ */
.password-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 40px 32px;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 380px;
    margin: 100px auto;
    box-shadow: var(--shadow-lg);
}

.password-container h2, .login-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-heading);
    text-align: center;
    margin-bottom: 24px;
}

.login-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: -16px;
    margin-bottom: 24px;
}

.password-container input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.password-container input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.password-container button {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent), #8b83ff);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--duration) var(--ease);
}

.password-container button:hover {
    background: linear-gradient(135deg, var(--accent-hover), #a09aff);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.35);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group.full-width {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    .nav-container { padding: 0 16px; }
    .nav-links { display: none; }
    .brand-badge { display: none; }
    .wrapper, .container-main { padding: 20px 16px; }
    
    .page-header h1 { font-size: 22px; }

    table { font-size: 12px; }
    th, td { padding: 10px 12px; }
    
    .modal-content { width: 95%; }
    .modal-header, .modal-body, .modal-footer { padding: 16px; }
    .modal-footer { flex-direction: column; }
    .modal-footer button { width: 100%; }

    .password-container { padding: 28px 20px; margin: 60px auto; }
}

@media (max-width: 480px) {
    .nav-container { height: 48px; }
    .page-header h1 { font-size: 20px; }
}

/* ============================================
   Focus-visible accessibility
   ============================================ */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   Utility animations
   ============================================ */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
