:root {
    --primary-clr: #3b82f6;
    --primary-hover: #2563eb;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --blur-intensity: blur(16px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Cairo', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* ═══════════════════════════════════════
   ANIMATED BACKGROUND
   ═══════════════════════════════════════ */
.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
    animation: float 15s infinite alternate ease-in-out;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: #3b82f6;
    top: -100px;
    right: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    bottom: -50px;
    left: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: #10b981;
    bottom: 20%;
    right: 20%;
    animation-duration: 20s;
}

@keyframes float {
    0% { transform: translateY(0) translateX(0); }
    100% { transform: translateY(30px) translateX(-30px); }
}

/* ═══════════════════════════════════════
   GLASSMORPHISM CONTAINER
   ═══════════════════════════════════════ */
.container {
    width: 92%;
    max-width: 900px;
    background: var(--bg-card);
    backdrop-filter: var(--blur-intensity);
    -webkit-backdrop-filter: var(--blur-intensity);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin: 2rem auto;
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */
.header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════
   TOP NAV BAR
   ═══════════════════════════════════════ */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
    background: var(--primary-clr);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-full { width: 100%; }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    box-shadow: none;
}

.btn-sm {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════ */
input, textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

input:focus, textarea:focus {
    border-color: var(--primary-clr);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-row {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
}

/* ═══════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════ */
.login-container {
    max-width: 450px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    color: var(--danger);
    font-size: 0.9rem;
    text-align: center;
}

/* ═══════════════════════════════════════
   ADMIN SECTIONS
   ═══════════════════════════════════════ */
.admin-container {
    max-width: 850px;
}

body:has(.admin-container),
body:has(.dashboard-container) {
    align-items: flex-start;
    padding: 2rem 0;
}

.admin-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.admin-section {
    margin-top: 1.5rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.2rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header-row .section-title {
    margin-bottom: 0;
}

.section-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ═══════════════════════════════════════
   USER CARDS
   ═══════════════════════════════════════ */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    transition: all 0.2s ease;
    animation: slideIn 0.3s ease;
}

.user-card:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
}

.user-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-weight: 700;
    font-size: 1rem;
}

.user-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 28px;
}

.cred-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.user-card-footer {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

.empty-msg {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    opacity: 0.7;
}

/* ═══════════════════════════════════════
   STAT CHIPS
   ═══════════════════════════════════════ */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0.8rem;
    padding: 0.6rem 0.8rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.stats-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stats-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stat-chip {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.stat-total {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.stat-ok {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.stat-err {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ═══════════════════════════════════════
   FORM MESSAGES
   ═══════════════════════════════════════ */
.form-msg {
    font-size: 0.85rem;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    text-align: center;
}

.msg-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.msg-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

/* ═══════════════════════════════════════
   HISTORY LOG
   ═══════════════════════════════════════ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    animation: slideIn 0.3s ease;
}

.history-item:hover {
    background: rgba(30, 41, 59, 0.8);
}

.history-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-account {
    font-weight: 600;
    font-size: 0.95rem;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════
   DASHBOARD TABLE
   ═══════════════════════════════════════ */
.dashboard-container {
    max-width: 1100px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

th {
    padding: 10px 14px;
    color: var(--primary-clr);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}

.token-cell {
    color: var(--text-secondary);
    font-family: monospace;
    word-break: break-all;
    max-width: 180px;
    font-size: 0.78rem;
}

.msg-cell {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.msg-line {
    margin-bottom: 3px;
}

/* Status Icons */
.status-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 11px;
}

.status-running {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid #f59e0b;
}

.status-done {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid #10b981;
}

/* Status Container */
.status-container {
    text-align: center;
    margin-top: 1.2rem;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    border: 1px solid var(--border-color);
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); max-height: 200px; }
    to { opacity: 0; transform: translateX(-20px); max-height: 0; padding: 0; margin: 0; overflow: hidden; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 640px) {
    .container { padding: 1.2rem; }
    .header h1 { font-size: 1.5rem; }
    .form-row { flex-direction: column; }
    .top-nav { flex-direction: column; align-items: flex-start; }
    .admin-header-row { flex-direction: column; align-items: flex-start; }
    table { font-size: 0.75rem; }
    th, td { padding: 8px 10px; }
}
