/* ============================================
   Admin Dashboard Styles v2
   ============================================ */

/* Login */
.admin-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-50);
}
.login-card {
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-card .ck-field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.login-card .ck-field input {
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font-body);
    color: var(--gray-800);
}
.login-card .ck-field input:focus {
    outline: none;
    border-color: var(--green-400);
    box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}
.login-hint {
    text-align: center;
    font-size: .75rem;
    color: var(--gray-400);
    margin-top: 12px;
}

/* Dashboard Layout */
.admin-dash {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 240px;
    background: var(--gray-800);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}
.admin-sidebar .logo-name { color: white; }
.admin-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 500;
    color: var(--gray-400);
    cursor: pointer;
    transition: all .15s;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active {
    color: white;
    background: var(--green-600);
    font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; }
.admin-sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Main */
.admin-main {
    flex: 1;
    margin-left: 240px;
    background: var(--gray-50);
    padding: 32px;
    min-height: 100vh;
}

/* Tabs */
.admin-tab { display: none; }
.admin-tab.active { display: block; }
.admin-tab h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gray-800);
    margin-bottom: 24px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.stat-card {
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all .2s;
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-label {
    display: block;
    font-size: .78rem;
    color: var(--gray-400);
    font-weight: 500;
    margin-bottom: 2px;
}
.stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--gray-800);
}

/* Cards */
.admin-card {
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.admin-card h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--gray-800);
    margin-bottom: 16px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Table */
.table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.admin-table th {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid var(--gray-100);
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-50);
    color: var(--gray-600);
}
.admin-table tr:hover td { background: var(--gray-50); }

.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 40px 14px !important;
    font-style: italic;
}

/* Status pills */
.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
}
.pill-pending { background: #fef3c7; color: #92400e; }
.pill-paid, .pill-delivered, .pill-available, .pill-active { background: var(--green-100); color: var(--green-700); }
.pill-failed, .pill-expired, .pill-cancelled { background: #fee2e2; color: #991b1b; }
.pill-sold { background: #e0e7ff; color: #3730a3; }
.pill-flagged { background: #fef3c7; color: #92400e; }

/* Tab header */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.tab-header h1 { margin-bottom: 0; }
.tab-filters {
    display: flex;
    gap: 8px;
    align-items: center;
}
.tab-filters select,
.tab-filters input {
    padding: 8px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .85rem;
    color: var(--gray-700);
    background: white;
    font-family: var(--font-body);
}
.tab-filters input:focus,
.tab-filters select:focus {
    outline: none;
    border-color: var(--green-400);
    box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}

/* Action Buttons */
.action-cell {
    display: flex;
    gap: 4px;
    align-items: center;
}
.action-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-200);
    background: white;
    color: var(--gray-500);
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
}
.action-btn:hover {
    border-color: var(--green-400);
    color: var(--green-600);
    background: var(--green-50);
}
.action-btn.green { border-color: var(--green-300); color: var(--green-600); }
.action-btn.green:hover { background: var(--green-100); }
.action-btn.red { border-color: #fca5a5; color: #ef4444; }
.action-btn.red:hover { background: #fee2e2; }
.action-btn.blue { border-color: #93c5fd; color: #3b82f6; }
.action-btn.blue:hover { background: #dbeafe; }
.action-btn.orange { border-color: #fcd34d; color: #f59e0b; background: #fef3c7; }
.action-btn svg { width: 14px; height: 14px; }

/* Inline select in table */
.inline-select {
    padding: 4px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: .78rem;
    font-family: var(--font-body);
    color: var(--gray-700);
    background: white;
    cursor: pointer;
}
.inline-select:focus {
    outline: none;
    border-color: var(--green-400);
}

/* Add Form */
.add-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.add-form .ck-field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.add-form select,
.add-form input[type="text"],
.add-form input[type="email"],
.add-form input[type="password"],
.add-form input[type="number"],
.add-form input[type="date"] {
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font-body);
    color: var(--gray-800);
    background: white;
}
.add-form select:focus,
.add-form input:focus {
    outline: none;
    border-color: var(--green-400);
    box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}
.add-result {
    font-size: .85rem;
    font-weight: 500;
    margin-top: 8px;
}
.add-result.success { color: var(--green-600); }
.add-result.error { color: var(--red-500); }

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn .2s ease;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
}
.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    background: white;
    font-size: 1.2rem;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.modal-close:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Order Detail Grid */
.order-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.od-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-50);
}
.od-label {
    font-size: .82rem;
    color: var(--gray-400);
    font-weight: 500;
}

/* Audit Log */
.audit-list {
    max-height: 300px;
    overflow-y: auto;
}
.audit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-50);
    font-size: .85rem;
}
.audit-action { color: var(--gray-700); }
.audit-time { color: var(--gray-400); font-size: .78rem; }
.empty-hint {
    color: var(--gray-400);
    font-style: italic;
    font-size: .85rem;
    padding: 16px 0;
}

/* Toast */
.admin-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    background: var(--gray-800);
    color: white;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    z-index: 300;
    opacity: 0;
    transform: translateY(20px);
    transition: all .3s ease;
    pointer-events: none;
}
.admin-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 1200px) {
    .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .admin-sidebar {
        width: 60px;
    }
    .admin-sidebar .logo-name,
    .admin-nav .nav-item span,
    .admin-sidebar-footer .nav-item span {
        display: none;
    }
    .nav-item { justify-content: center; padding: 10px; }
    .admin-main { margin-left: 60px; padding: 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}
