/* ============================================
   SAVIONYX - Sales Monitoring System
   Main Stylesheet
   ============================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --text: #334155;
    --text-muted: #94a3b8;
    --sidebar-width: 240px;
    --navbar-height: 60px;
}

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

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

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    gap: 16px;
}

.navbar-brand a {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 2px;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text);
}

.navbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-user span {
    color: var(--text);
    font-weight: 500;
}

.btn-logout {
    background: var(--danger);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-logout:hover { background: #b91c1c; }

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

.layout {
    display: flex;
    padding-top: var(--navbar-height);
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.nav-menu {
    list-style: none;
    padding: 16px 0;
}

.nav-menu li a {
    display: block;
    padding: 11px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.nav-menu li a:hover,
.nav-menu li a.active {
    background: rgba(37, 99, 235, 0.15);
    color: #fff;
    border-left-color: var(--primary);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px;
    min-height: calc(100vh - var(--navbar-height));
}

/* ============================================
   CARDS & CONTAINERS
   ============================================ */

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 20px;
}

.card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
}

/* ============================================
   STATS CARDS
   ============================================ */

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

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

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

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

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

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-wrap {
    margin-bottom: 16px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text);
    margin-bottom: 6px;
    font-weight: 500;
}

.progress-bar {
    background: var(--border);
    border-radius: 20px;
    height: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 20px;
    background: var(--primary);
    transition: width 0.5s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ============================================
   FUNNEL CHART
   ============================================ */

.funnel-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 16px 0;
}

.funnel-item {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 500px;
    gap: 10px;
}

.funnel-bar {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.funnel-segment {
    height: 44px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    transition: width 0.5s ease;
}

.funnel-label {
    min-width: 90px;
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
}

.funnel-count {
    min-width: 36px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: var(--dark);
}

/* ============================================
   TABLES
   ============================================ */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: #f1f5f9;
    color: var(--text);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-size: 13.5px;
}

table tr:hover td {
    background: #f8fafc;
}

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

/* ============================================
   BADGES / STAGE
   ============================================ */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-new_lead    { background: #dbeafe; color: #1d4ed8; }
.badge-contacting  { background: #ede9fe; color: #6d28d9; }
.badge-meeting     { background: #fef9c3; color: #92400e; }
.badge-penawaran   { background: #ffedd5; color: #c2410c; }
.badge-win         { background: #dcfce7; color: #166534; }
.badge-lost        { background: #fee2e2; color: #991b1b; }
.badge-lunas       { background: #dcfce7; color: #166534; }
.badge-belum_lunas { background: #fef3c7; color: #92400e; }
.badge-aktif       { background: #fef9c3; color: #92400e; }
.badge-active      { background: #dcfce7; color: #166534; }
.badge-inactive    { background: #fee2e2; color: #991b1b; }

/* ============================================
   FORMS
   ============================================ */

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

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }

.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #475569; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--light); }

.btn-block { width: 100%; justify-content: center; }

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
}

.alert-success  { background: #dcfce7; color: #166534; border-left: 4px solid #16a34a; }
.alert-danger   { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.alert-warning  { background: #fef3c7; color: #92400e; border-left: 4px solid #d97706; }
.alert-info     { background: #e0f2fe; color: #075985; border-left: 4px solid #0891b2; }

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

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: #fff;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ============================================
   PRODUCT ROWS (for visit input)
   ============================================ */

.product-rows {
    margin-bottom: 12px;
}

.product-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr 1.5fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

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

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

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

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 20px;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
}

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

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

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

    .navbar-toggle {
        display: block;
    }

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

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

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

    .product-row {
        grid-template-columns: 1fr 1fr;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-box {
        padding: 28px 20px;
    }
}
