/* ===================================
   Kadma Partner Portal - CSS
   =================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #e85d04;
    --accent: #e85d04;
    --accent-light: #fff1e6;
    --topbar-h: 60px;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    margin: 0;
}

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

.auth-layout {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 520px;
    padding: 24px 16px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    flex-shrink: 0;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--accent);
}

.auth-tagline {
    color: #94a3b8;
    font-size: 13px;
    margin: 8px 0 0;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.auth-card-lg {
    padding: 28px 32px;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text);
}

.auth-subtitle {
    color: var(--text-muted);
    margin: 0 0 24px;
    font-size: 13px;
}

.auth-form .form-label {
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 5px;
}

.auth-form .form-control {
    border-radius: 8px;
    border-color: var(--border);
    padding: 9px 12px;
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
}

.auth-form .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232,93,4,0.12);
}

.btn-auth {
    width: 100%;
    padding: 11px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    background: var(--accent);
    border-color: var(--accent);
}

.btn-auth:hover {
    background: #c44d00;
    border-color: #c44d00;
}

.form-action { margin-top: 20px; }

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-link a { color: var(--accent); font-weight: 500; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

.auth-note {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 20px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.auth-note svg { flex-shrink: 0; margin-top: 1px; }

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: #64748b;
    font-size: 12px;
}

/* ===================================
   PARTNER LAYOUT (SIDEBAR)
   =================================== */

.partner-layout { margin: 0; }

.partner-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .3s;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-logo .logo-text {
    font-size: 17px;
    color: #fff;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
}

/* Partner info */
.sidebar-partner-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.partner-avatar {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.partner-meta { min-width: 0; }

.partner-name {
    color: #f1f5f9;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.partner-email {
    color: #64748b;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Affiliate code box */
.sidebar-code-box {
    margin: 12px 14px;
    background: rgba(232,93,4,0.12);
    border: 1px solid rgba(232,93,4,0.3);
    border-radius: 10px;
    padding: 12px 14px;
}

.code-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.code-value {
    font-size: 16px;
    font-weight: 800;
    color: #fb923c;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #cbd5e1;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s, color .2s;
    width: 100%;
    justify-content: center;
    margin-bottom: 8px;
}

.btn-copy:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.code-rate {
    font-size: 11px;
    color: #64748b;
    text-align: center;
}

.code-rate strong { color: #4ade80; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background .2s, color .2s;
    margin-bottom: 2px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #f1f5f9;
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.btn-logout {
    color: #64748b;
}

.btn-logout:hover {
    background: rgba(239,68,68,0.1);
    color: #f87171;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.show { display: block; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: none;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.topbar-right {
    color: var(--text-muted);
    font-size: 13px;
}

.topbar-greeting strong { color: var(--text); }

/* Page body */
.page-body { flex: 1; }

.page-content { padding: 24px; }

/* ===================================
   STATS GRID
   =================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon--blue   { background: #eff6ff; color: #2563eb; }
.stat-icon--green  { background: #f0fdf4; color: #16a34a; }
.stat-icon--orange { background: #fff7ed; color: #ea580c; }
.stat-icon--purple { background: #faf5ff; color: #9333ea; }
.stat-icon--teal   { background: #f0fdfa; color: #0d9488; }
.stat-icon--red    { background: #fef2f2; color: #dc2626; }

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===================================
   INFO BANNER
   =================================== */

.info-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #1e40af;
}

.info-banner-icon {
    flex-shrink: 0;
    color: #3b82f6;
}

.info-banner-body { flex: 1; line-height: 1.5; }

.info-banner--warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}
.info-banner--warning .info-banner-icon { color: #f59e0b; }

/* ===================================
   SECTION CARD
   =================================== */

.section-card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

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

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.section-link {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.section-link:hover { text-decoration: underline; }

/* ===================================
   ORDER TABLE
   =================================== */

.order-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.order-table th {
    background: #f8fafc;
    padding: 11px 14px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.order-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.order-table tbody tr:last-child td { border-bottom: none; }

.order-table-full { min-width: 900px; }

.order-row-main td { background: #fff; }
.order-row-detail td { background: #fafafa; }
.order-row-detail td.product-cell { padding-left: 24px; }

/* Cell styles */
.order-meta-cell { vertical-align: top; }

.order-id {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    font-family: monospace;
}

.order-date-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

.info-label {
    color: #94a3b8;
}

.customer-cell { vertical-align: top; }
.customer-name { font-weight: 500; color: var(--text); }
.customer-phone { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.customer-email { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.product-cell .product-name {
    color: var(--text);
    font-weight: 500;
    line-height: 1.4;
}

.product-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.voucher-cell { vertical-align: top; }

.voucher-code {
    display: inline-block;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    font-family: monospace;
    padding: 2px 8px;
    border-radius: 5px;
    letter-spacing: 0.5px;
}

.discount-amount {
    font-size: 12px;
    color: #dc2626;
    margin-top: 4px;
}

.price-cell { vertical-align: top; }
.price-total { font-weight: 600; color: var(--text); }
.price-discount { font-size: 12px; color: #dc2626; }
.price-effective { font-size: 12px; font-weight: 600; color: #16a34a; margin-top: 2px; }

.commission-cell { vertical-align: top; }

.commission-amount {
    font-size: 15px;
    font-weight: 700;
}

.commission--confirmed { color: #16a34a; }
.commission--pending   { color: #d97706; }

.commission-rate {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.commission-label {
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dbeafe; color: #1d4ed8; }
.badge-shipping  { background: #e0f2fe; color: #0369a1; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-secondary { background: #f3f4f6; color: #6b7280; }

/* Pagination */
.table-pagination {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.table-pagination .pagination { margin-bottom: 0; }

.page-link {
    color: var(--accent);
    border-radius: 6px !important;
    margin: 0 2px;
    font-size: 13px;
}

.page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
}

/* ===================================
   FILTER BAR
   =================================== */

.filter-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.filter-form { flex: 1; }

.filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-field { flex: 1; min-width: 140px; }

.filter-field .form-control,
.filter-field .form-select {
    font-size: 13px;
    border-color: var(--border);
    border-radius: 7px;
}

.filter-field .form-control:focus,
.filter-field .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232,93,4,0.1);
}

.filter-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.filter-actions .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    border-radius: 7px;
    font-size: 13px;
}

.filter-actions .btn-primary:hover {
    background: #c44d00;
    border-color: #c44d00;
}

.filter-summary {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===================================
   EMPTY STATE
   =================================== */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p { margin: 0 0 6px; }

/* ===================================
   ORDER TABLE COMPACT (DASHBOARD)
   =================================== */

.order-no { font-weight: 600; font-family: monospace; font-size: 12px; }

.order-date {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.price-value { font-weight: 600; color: var(--text); }

.commission-value { font-weight: 700; font-size: 14px; }

/* ===================================
   BOOTSTRAP OVERRIDES
   =================================== */

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover, .btn-primary:focus {
    background: #c44d00;
    border-color: #c44d00;
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.invalid-feedback { font-size: 12px; }

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
    border-radius: 8px;
    font-size: 13px;
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .topbar-toggle { display: block; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-value { font-size: 18px; }

    .filter-row { flex-direction: column; }
    .filter-field { min-width: 100%; }

    .info-banner { flex-wrap: wrap; }
    .info-banner .btn { width: 100%; }

    .page-content { padding: 16px; }

    .auth-card { padding: 24px 20px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .auth-card-lg { padding: 20px 16px; }
}
