/* ============================================
   LEATHER STORES ADMIN PANEL
   Dark professional theme
   ============================================ */

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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #222534;
    --bg-hover: #2a2e3f;
    --border: #2e3347;
    --text-primary: #e8eaf0;
    --text-secondary: #8b90a0;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --store-gay: #dc2626;
    --store-leather: #d97706;
    --store-north: #c5a03f;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

.hidden { display: none !important; }

/* ============================================
   LOGIN
   ============================================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1040 100%);
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    width: 400px;
    max-width: 90vw;
}

.login-box h1 { font-size: 24px; margin-bottom: 8px; }
.login-box p { color: var(--text-secondary); margin-bottom: 32px; }

.login-box input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 16px;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover { background: var(--accent-hover); }

.error { color: var(--danger); font-size: 14px; margin-top: 12px; }

/* ============================================
   HEADER
   ============================================ */

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left h1 { font-size: 18px; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right select {
    padding: 8px 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.btn-outline {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* ============================================
   LAYOUT
   ============================================ */

.admin-layout {
    display: flex;
    min-height: calc(100vh - 65px);
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    flex-shrink: 0;
}

.nav-item {
    display: block;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ============================================
   SECTIONS
   ============================================ */

.section { display: none; }
.section.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 { font-size: 20px; font-weight: 600; }

.btn-primary {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   DATA GRID (tables)
   ============================================ */

.data-grid {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-grid table {
    width: 100%;
    border-collapse: collapse;
}

.data-grid th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.data-grid td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.data-grid tr:hover td { background: var(--bg-hover); }

.store-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.store-badge.gayleather { background: rgba(220, 38, 38, 0.15); color: #f87171; }
.store-badge.leathershop { background: rgba(217, 119, 6, 0.15); color: #fbbf24; }
.store-badge.northbeach { background: rgba(197, 160, 63, 0.15); color: #d4af37; }

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-badge.completed { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-badge.shipped { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.status-badge.cancelled { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.action-btns { display: flex; gap: 8px; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm.danger:hover { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: #f87171; }
.btn-sm.edit:hover { background: rgba(99, 102, 241, 0.15); color: #818cf8; border-color: #818cf8; }

.empty-state {
    padding: 48px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state p { margin-top: 8px; font-size: 14px; }

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 560px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body { padding: 24px; }

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-ai {
    padding: 8px 14px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ai:hover { background: rgba(139, 92, 246, 0.25); }

/* ============================================
   AI TOOLS
   ============================================ */

.ai-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.ai-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.ai-card h3 { font-size: 16px; margin-bottom: 16px; }

.ai-card form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-card input,
.ai-card select {
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
}

.ai-result {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ============================================
   STATS DASHBOARD
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-breakdown {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.stats-breakdown h3 { font-size: 16px; margin-bottom: 16px; }

.store-stats-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.store-stats-row:last-child { border-bottom: none; }

.store-stats-row .store-name {
    width: 140px;
    font-weight: 600;
}

.store-stats-row .store-counts {
    display: flex;
    gap: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.store-stats-row .store-counts span {
    display: flex;
    gap: 4px;
}

.store-stats-row .store-counts strong {
    color: var(--text-primary);
}

/* ============================================
   TOAST
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.info { background: var(--accent); color: white; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 0; }
    .nav-item { padding: 12px 16px; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
    .nav-item.active { border-left: none; border-bottom-color: var(--accent); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .ai-tools-grid { grid-template-columns: 1fr; }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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