/* ============================================
   KOPERASI KOMIU - Design System
   Tema: Hijau, Putih, Kuning
   ============================================ */

/* Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================
   CSS Variables / Design Tokens
   ============================================ */
:root {
    /* Primary - Hijau */
    --primary-50: #f0fdf4;
    --primary-100: #dcfce7;
    --primary-200: #bbf7d0;
    --primary-300: #86efac;
    --primary-400: #4ade80;
    --primary-500: #22c55e;
    --primary-600: #16a34a;
    --primary-700: #15803d;
    --primary-800: #166534;
    --primary-900: #14532d;
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #22c55e;
    --primary-glow: rgba(22, 163, 74, 0.15);

    /* Secondary - Kuning */
    --secondary-50: #fffbeb;
    --secondary-100: #fef3c7;
    --secondary-200: #fde68a;
    --secondary-300: #fcd34d;
    --secondary-400: #fbbf24;
    --secondary-500: #f59e0b;
    --secondary-600: #d97706;
    --secondary: #fbbf24;
    --secondary-dark: #f59e0b;

    /* Neutral */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Status */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Surface */
    --surface: #ffffff;
    --surface-alt: #f0fdf4;
    --surface-hover: #f8fafc;
    --body-bg: #f0fdf4;

    /* Text */
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #ffffff;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 64px;
    --bottom-nav-height: 68px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.12);
    --shadow-primary: 0 4px 16px rgba(22, 163, 74, 0.25);
    --shadow-secondary: 0 4px 16px rgba(251, 191, 36, 0.25);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--body-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; display: block; }

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--gray-800);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ============================================
   Layout Utilities
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.hidden { display: none !important; }

/* ============================================
   Grid System
   ============================================ */
.grid {
    display: grid;
    gap: 1rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .grid-6 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   Card
   ============================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
}
.card-header h3, .card-header h4 {
    font-size: 1rem;
    font-weight: 600;
}
.card-body {
    padding: 1.25rem;
}
.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* Stat Card */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--gray-100);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 0 0 0 80px;
    opacity: 0.08;
    transition: opacity var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
}
.stat-card .stat-icon.green {
    background: var(--primary-100);
    color: var(--primary-700);
}
.stat-card .stat-icon.green svg { stroke: var(--primary-600); }
.stat-card .stat-icon.yellow {
    background: var(--secondary-100);
    color: var(--secondary-600);
}
.stat-card .stat-icon.yellow svg { stroke: var(--secondary-600); }
.stat-card .stat-icon.blue {
    background: #dbeafe;
    color: #2563eb;
}
.stat-card .stat-icon.blue svg { stroke: #2563eb; }
.stat-card .stat-icon.red {
    background: #fee2e2;
    color: #dc2626;
}
.stat-card .stat-icon.red svg { stroke: #dc2626; }
.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.stat-card .stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-weight: 500;
}
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
}
.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.btn:active {
    transform: scale(0.97);
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-white);
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.3);
    color: var(--text-white);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: var(--gray-800);
    box-shadow: var(--shadow-secondary);
}
.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.35);
    color: var(--gray-800);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-200);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: var(--text-white);
}
.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
    color: var(--text-white);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}
.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}
.btn-sm svg { width: 16px; height: 16px; }

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}
.btn-icon.sm { width: 32px; height: 32px; }

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}
.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}
.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control::placeholder {
    color: var(--text-muted);
}
.form-control:disabled, .form-control[readonly] {
    background: var(--gray-50);
    cursor: not-allowed;
}
.form-control.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

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

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

/* Input group */
.input-group {
    position: relative;
    display: flex;
}
.input-group .form-control {
    flex: 1;
}
.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    white-space: nowrap;
}
.input-group-text:first-child {
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-group-text:last-child {
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.input-group .form-control:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-group .form-control:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.input-group .form-control:not(:first-child):not(:last-child) {
    border-radius: 0;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}
table {
    width: 100%;
    border-collapse: collapse;
}
table th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-100);
    text-align: left;
    white-space: nowrap;
}
table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
table tbody tr {
    transition: background var(--transition-fast);
}
table tbody tr:hover {
    background: var(--primary-50);
}
table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.4;
}
.badge-success {
    background: #dcfce7;
    color: #15803d;
}
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}
.badge-info {
    background: #dbeafe;
    color: #1e40af;
}
.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}
.badge-primary {
    background: var(--primary-100);
    color: var(--primary-800);
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-100);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: color var(--transition-fast);
}
.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    border-radius: 2px 2px 0 0;
    transition: background var(--transition-fast);
}
.tab-btn:hover {
    color: var(--primary);
}
.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
}
.tab-btn.active::after {
    background: var(--primary);
}
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 1rem 0;
}
.pagination .page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.pagination .page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pagination .page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-white);
}
.pagination .page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   Progress Bar
   ============================================ */
.progress {
    height: 8px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width var(--transition-slow);
}
.progress-bar.warning {
    background: linear-gradient(90deg, var(--secondary-dark), var(--secondary));
}
.progress-bar.danger {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    stroke: var(--gray-300);
}
.empty-state h4 {
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}
.empty-state p {
    font-size: 0.875rem;
    max-width: 320px;
    margin: 0 auto;
}

/* ============================================
   Avatar
   ============================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--primary-100);
    color: var(--primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.25rem; }

/* ============================================
   Divider
   ============================================ */
.divider {
    height: 1px;
    background: var(--gray-100);
    margin: 1rem 0;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-fadeInUp { animation: fadeInUp 0.4s ease; }
.animate-slideUp { animation: slideUp 0.3s ease; }
.animate-scaleIn { animation: scaleIn 0.2s ease; }

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
