/* ===================================================== */
/* APOTEK DEWI - DESIGN SYSTEM                           */
/* Sistem Informasi Manajemen Stok Multi-Cabang          */
/* ===================================================== */

/* Color Palette */
:root {
    --primary: #2563EB;       /* Blue */
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --bg: #F9FAFB;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --text-dark: #111827;
    --text-mid: #6B7280;
    --text-light: #9CA3AF;
    --sidebar-bg: #FFFFFF;
}
.card canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =============== LAYOUT =============== */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 42px; height: 42px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 18px;
}

.sidebar-brand h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}
.sidebar-brand p {
    font-size: 10px;
    color: var(--text-mid);
    margin: 0;
}

.sidebar-menu { padding: 16px 0; }
.sidebar-menu .menu-section {
    padding: 12px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 700;
    letter-spacing: 1px;
}
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-mid);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-menu a:hover {
    background: var(--bg);
    color: var(--primary);
    text-decoration: none;
}
.sidebar-menu a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-menu a .icon {
    width: 18px;
    text-align: center;
}

.main-wrapper {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-dark); }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.user-info { line-height: 1.2; }
.user-info .name { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.user-info .role { font-size: 11px; color: var(--text-mid); }

.content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}
.page-header .subtitle {
    color: var(--text-mid);
    font-size: 14px;
    margin-top: 4px;
}

.breadcrumb {
    color: var(--text-mid);
    font-size: 12px;
    margin-bottom: 8px;
}
.breadcrumb a { color: var(--text-mid); }

/* =============== CARDS =============== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}

/* Stat Cards (Dashboard) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
}
.stat-icon {
    width: 50px; height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary); }
.stat-icon.green { background: var(--success); }
.stat-icon.orange { background: var(--warning); }
.stat-icon.red { background: var(--danger); }
.stat-icon.purple { background: #8B5CF6; }

.stat-info .label {
    font-size: 12px;
    color: var(--text-mid);
    margin-bottom: 4px;
}
.stat-info .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}
.stat-info .trend {
    font-size: 11px;
    color: var(--success);
    margin-top: 2px;
}

/* =============== BUTTONS =============== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

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

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary-light); color: var(--primary); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; color: white; }

.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 6px; min-width: 32px; }

.btn-group { display: inline-flex; gap: 4px; }

/* =============== FORMS =============== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}
.form-label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-control.error { border-color: var(--danger); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.error-text {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}
.helper-text {
    color: var(--text-mid);
    font-size: 12px;
    margin-top: 4px;
}

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

/* =============== TABLES =============== */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.table-toolbar {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.table-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}
.table-filters input,
.table-filters select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    min-width: 180px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table thead th {
    background: #F9FAFB;
    padding: 12px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dark);
}
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }

.action-cell { white-space: nowrap; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-mid);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }

/* =============== BADGES =============== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge.success { background: #D1FAE5; color: #065F46; }
.badge.warning { background: #FEF3C7; color: #92400E; }
.badge.danger { background: #FEE2E2; color: #991B1B; }
.badge.info { background: #DBEAFE; color: #1E40AF; }
.badge.neutral { background: #F3F4F6; color: #374151; }

/* =============== ALERTS =============== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: #D1FAE5; color: #065F46; border-left: 4px solid var(--success); }
.alert-danger { background: #FEE2E2; color: #991B1B; border-left: 4px solid var(--danger); }
.alert-warning { background: #FEF3C7; color: #92400E; border-left: 4px solid var(--warning); }
.alert-info { background: #DBEAFE; color: #1E40AF; border-left: 4px solid var(--info); }

/* =============== LOGIN PAGE =============== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}
.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: 16px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    font-weight: 800;
}
.login-header h1 {
    font-size: 24px;
    color: var(--text-dark);
    margin-bottom: 4px;
}
.login-header p {
    color: var(--text-mid);
    font-size: 13px;
}
.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-mid);
    font-size: 11px;
}

/* =============== TWO-COLUMN LAYOUT =============== */
.row-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.row-layout-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* =============== DETAIL/INVOICE STYLES =============== */
.detail-header {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
}
.detail-header dt {
    font-size: 11px;
    color: var(--text-mid);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 2px;
}
.detail-header dd {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 600;
}

.total-row {
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 16px;
}
.total-row td { color: white !important; padding: 16px 14px !important; }

/* =============== TRANSACTION ITEMS TABLE =============== */
.items-table input,
.items-table select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}
.items-table input:focus, .items-table select:focus {
    outline: none;
    border-color: var(--primary);
}
.items-table .qty-input,
.items-table .price-input { text-align: right; }
.items-table .subtotal-display {
    text-align: right;
    font-weight: 600;
    color: var(--text-dark);
    padding: 6px 8px;
}
.items-table .stock-info {
    font-size: 11px;
    color: var(--text-mid);
    margin-top: 4px;
}
.items-table .stock-warning { color: var(--danger) !important; font-weight: 600; }

.btn-add-row {
    width: 100%;
    padding: 10px;
    border: 1.5px dashed var(--primary);
    color: var(--primary);
    background: transparent;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    font-family: inherit;
    font-size: 13px;
}
.btn-add-row:hover { background: var(--primary-light); }

/* =============== PAGINATION =============== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.pagination-info { color: var(--text-mid); font-size: 12px; }
.pagination-controls { display: flex; gap: 4px; }
.pagination-controls a, .pagination-controls span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-mid);
    font-size: 12px;
    text-decoration: none;
}
.pagination-controls a:hover { background: var(--primary-light); color: var(--primary); }
.pagination-controls .active { background: var(--primary); color: white; border-color: var(--primary); }

/* =============== MODAL =============== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    overflow: hidden;
}
.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-mid); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* =============== UTILITIES =============== */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-mid { color: var(--text-mid); }
.text-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

.d-flex { display: flex; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

.w-100 { width: 100%; }

/* =============== RESPONSIVE =============== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .row-layout, .row-layout-3 { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
