/* =====================================================
   Prima Bakery — Core Application Styles
   Theme: Merah Putih Elegan
   ===================================================== */

/* ── CSS Variables ── */
:root {
    --primary: #DC2626;
    --primary-dark: #991B1B;
    --primary-light: #FEE2E2;
    --primary-50: #FEF2F2;
    --secondary: #1F2937;
    --surface: #FFFFFF;
    --background: #F9FAFB;
    --success: #059669;
    --success-light: #D1FAE5;
    --warning: #D97706;
    --warning-light: #FEF3C7;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --info: #2563EB;
    --info-light: #DBEAFE;
    --gold: #B8860B;
    --border: #E5E7EB;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Global Reset ── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--background);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* ── Global Loader ── */
.global-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 0;
    visibility: hidden;
}
.global-loader.active {
    opacity: 1;
    visibility: visible;
}
.loader-content {
    text-align: center;
}
.loader-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Glassmorphism Card ── */
.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.glass-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:active {
    transform: scale(0.97);
}
.btn-primary {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    transform: translateY(-1px);
}
.btn-secondary {
    background: var(--secondary);
    color: white;
}
.btn-secondary:hover {
    background: #374151;
}
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary-50);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: #F3F4F6;
    color: var(--text-primary);
}
.btn-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}
.btn-danger {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    color: white;
}
.btn-warning {
    background: linear-gradient(135deg, #D97706 0%, #B45309 100%);
    color: white;
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-md);
}
.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}
.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}
.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: var(--radius-md);
}
.btn-icon.btn-sm {
    width: 1.75rem;
    height: 1.75rem;
}
.btn-icon.btn-sm svg {
    width: 0.875rem;
    height: 0.875rem;
}
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Form Inputs ── */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    outline: none;
    transition: var(--transition);
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.form-input::placeholder {
    color: var(--text-muted);
}
.form-input.is-error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8.825a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 0 1 .708-.708L6 7.617l3.646-3.646a.5.5 0 0 1 .708.708l-4 4A.5.5 0 0 1 6 8.825z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.5rem;
}
textarea.form-input {
    resize: vertical;
    min-height: 5rem;
}
.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* ── Badge ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-gray { background: #F3F4F6; color: #6B7280; }

/* ── Table ── */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.data-table thead th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: #F9FAFB;
    border-bottom: 2px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.data-table thead th:first-child {
    border-radius: var(--radius-lg) 0 0 0;
}
.data-table thead th:last-child {
    border-radius: 0 var(--radius-lg) 0 0;
}
.data-table tbody tr {
    transition: var(--transition);
}
.data-table tbody tr:hover {
    background: var(--primary-50);
}
.data-table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #F3F4F6;
    color: var(--text-primary);
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Card Stat ── */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.stat-card .stat-icon {
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
}
.stat-card .stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}
.stat-card .stat-change {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Toast Notifications ── */
.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--primary);
    min-width: 300px;
    max-width: 420px;
    animation: toastSlideIn 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
    transform: translateX(120%);
}
.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}
.toast-message {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}
.toast-close {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    background: none;
    border: none;
    font-size: 1.125rem;
    color: var(--text-secondary);
}
.toast-close:hover { opacity: 1; }

@keyframes toastSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}
.modal-box {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s cubic-bezier(0.21, 1.02, 0.73, 1);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.modal-close:hover {
    background: #F3F4F6;
    color: var(--text-primary);
}
.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}
.modal-box.modal-lg {
    max-width: 720px;
}
.modal-box.modal-xl {
    max-width: 900px;
}

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

/* ── Empty State ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}
.empty-state svg {
    width: 4rem;
    height: 4rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.empty-state h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.empty-state p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ── Skeleton Loading ── */
.skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}
.pagination .page-btn {
    min-width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.pagination .page-btn:hover:not(.active):not([disabled]) {
    background: var(--primary-50);
    color: var(--primary);
}
.pagination .page-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}
.pagination .page-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Utility Animations ── */
.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}
.animate-slide-up {
    animation: slideUp 0.3s ease forwards;
}
.animate-count-up {
    animation: none; /* handled by JS */
}

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

/* ── Print styles ── */
@media print {
    .sidebar, .toast-container, .modal-overlay, .btn, nav {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    body {
        background: white !important;
    }
}
