/* ============================
   DESIGN TOKENS
   ============================ */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f36;
    --bg-card-hover: #222845;
    --bg-input: #0f1629;
    --text-primary: #f1f5f9;
    --text-secondary: #8892b0;
    --text-muted: #5a6480;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.12);
    --red: #f43f5e;
    --red-bg: rgba(244, 63, 94, 0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.12);
    --orange: #f59e0b;
    --orange-bg: rgba(245, 158, 11, 0.12);
    --border: #252d4a;
    --border-light: #2e3856;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================
   RESET & BASE
   ============================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

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

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

.logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.logo h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: linear-gradient(135deg, var(--accent-light), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.nav-links {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.nav-links li {
    margin: 2px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.nav-links li:hover { background: rgba(255,255,255,0.03); }
.nav-links li:hover a { color: var(--text-primary); }

.nav-links li.active {
    background: var(--accent-glow);
}

.nav-links li.active a {
    color: var(--accent-light);
    font-weight: 600;
}

.nav-icon { font-size: 16px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--green);
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* ============================
   MAIN CONTENT
   ============================ */
.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================
   TOP BAR
   ============================ */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    z-index: 50;
}

.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 20px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.topbar-title {
    font-size: 17px;
    font-weight: 600;
    flex: 1;
}

.clock {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ============================
   PAGES
   ============================ */
.page {
    display: none;
    padding: 24px 28px 40px;
    animation: fadeIn 0.3s ease;
}
.page.active { display: block; }

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

/* ============================
   SUMMARY CARDS
   ============================ */
.cards-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.card-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.card-orders .card-value { color: var(--blue); }
.card-revenue .card-value { color: var(--orange); }
.card-profit .card-value { color: var(--green); }
.card-dp .card-value { color: var(--accent-light); }

.card-orders { border-left: 3px solid var(--blue); }
.card-revenue { border-left: 3px solid var(--orange); }
.card-profit { border-left: 3px solid var(--green); }
.card-dp { border-left: 3px solid var(--accent-light); }

/* ============================
   TOOLBAR
   ============================ */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.search-input, .filter-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    transition: border var(--transition);
    outline: none;
}

.search-input { min-width: 200px; flex: 1; max-width: 280px; }
.filter-select { min-width: 130px; cursor: pointer; }
.search-input:focus, .filter-select:focus { border-color: var(--accent); }

.search-input::placeholder { color: var(--text-muted); }

/* ============================
   BUTTONS
   ============================ */
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background var(--transition);
}

.btn-icon:hover { background: rgba(255,255,255,0.08); }
.btn-edit { color: var(--blue); }
.btn-delete { color: var(--red); }

/* ============================
   TABLE
   ============================ */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1350px;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    font-size: 12.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    background: rgba(0,0,0,0.25);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.6px;
    position: sticky;
    top: 0;
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

.profit-positive { color: var(--green); font-weight: 600; }
.profit-negative { color: var(--red); font-weight: 600; }

.settlement-pending { color: var(--orange); }
.settlement-paid { color: var(--green); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================
   PRODUCTS PAGE
   ============================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.product-category {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.product-category-header {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.cat-sablon .product-category-header { background: linear-gradient(135deg, rgba(59,130,246,0.15), transparent); color: var(--blue); }
.cat-bordir .product-category-header { background: linear-gradient(135deg, rgba(245,158,11,0.15), transparent); color: var(--orange); }
.cat-printing .product-category-header { background: linear-gradient(135deg, rgba(16,185,129,0.15), transparent); color: var(--green); }

.product-list { list-style: none; }

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: background var(--transition);
}

.product-item:last-child { border-bottom: none; }
.product-item:hover { background: rgba(255,255,255,0.02); }

.product-item .price {
    font-weight: 600;
    color: var(--accent-light);
    font-variant-numeric: tabular-nums;
}

/* ============================
   MODAL
   ============================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
    animation: modalIn 0.3s ease;
}

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

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

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

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

.modal-close:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }

form { padding: 24px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

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

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

.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }

.form-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ============================
   TOAST
   ============================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    min-width: 260px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ============================
   SIDEBAR OVERLAY (mobile)
   ============================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

/* ============================
   RESPONSIVE: Tablet
   ============================ */
@media (max-width: 1024px) {
    .cards-row { grid-template-columns: repeat(2, 1fr); }
    .products-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================
   RESPONSIVE: Mobile
   ============================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close { display: block; }
    .sidebar-overlay.active { display: block; }

    .content { margin-left: 0; }

    .hamburger { display: block; }

    .topbar { padding: 0 16px; }

    .page { padding: 16px; }

    .cards-row { grid-template-columns: 1fr 1fr; gap: 10px; }

    .card { padding: 14px; }
    .card-value { font-size: 17px; }
    .card-label { font-size: 10px; }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left {
        flex-direction: column;
    }

    .search-input { max-width: 100%; min-width: auto; }

    .btn-primary { width: 100%; text-align: center; }

    .products-grid { grid-template-columns: 1fr; }

    .form-grid { grid-template-columns: 1fr; }

    .modal { max-width: 100%; margin: 10px; }
}

@media (max-width: 420px) {
    .cards-row { grid-template-columns: 1fr; }

    .topbar-title { font-size: 14px; }
}

/* ============================
   SCROLLBAR
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
