/**
 * AmarHisab Design System - Green Banking Theme
 * Professional finance application design with green-driven palette
 * Version: 1.0.0
 */

/* ============================================
   1. DESIGN TOKENS (CSS Variables)
   ============================================ */

:root {
    /* Primary Palette - Green Banking */
    --color-primary: #0D6B3E;
    --color-primary-600: #0F7C44;
    --color-primary-700: #0A5530;
    --color-accent: #95E26A;
    --color-accent-500: #C6F3A5;
    --color-accent-600: #7FD14F;

    /* Neutrals */
    --bg: #F6F8FA;
    --surface: #FFFFFF;
    --muted: #9AA3AD;
    --text: #0B1B17;
    --line: #E6E9EC;

    /* Status Colors */
    --success: #2E9E46;
    --danger: #E44D4D;
    --warning: #F2A64A;
    --info: #3B82F6;

    /* Typography Scale */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-size-h1: 28px;
    --font-size-h2: 20px;
    --font-size-body: 15px;
    --font-size-small: 13px;
    --font-size-xs: 11px;

    --font-weight-regular: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-heading: 1.3;
    --line-height-body: 1.5;

    /* Spacing Scale (8px base) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-soft: 0 6px 18px rgba(12, 30, 20, 0.06);
    --shadow-medium: 0 10px 25px rgba(12, 30, 20, 0.1);
    --shadow-strong: 0 20px 40px rgba(12, 30, 20, 0.15);
    --shadow-focus: 0 0 0 3px rgba(13, 107, 62, 0.12);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index Scale */
    --z-dropdown: 50;
    --z-modal: 100;
    --z-toast: 200;
    --z-tooltip: 300;
}

/* Dark Mode / Soft Theme (optional) */
[data-theme="soft"] {
    --bg: #F0F9F4;
    --surface: #FAFFFE;
    --color-accent-500: #D4F5C3;
}

/* ============================================
   2. GLOBAL RESETS & BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    color: var(--text);
    background: var(--bg);
    font-weight: var(--font-weight-regular);
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
}

ul,
ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* ============================================
   3. TYPOGRAPHY
   ============================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-heading);
    color: var(--text);
    margin: 0;
}

h1,
.text-h1 {
    font-size: var(--font-size-h1);
    font-weight: var(--font-weight-bold);
}

h2,
.text-h2 {
    font-size: var(--font-size-h2);
    font-weight: var(--font-weight-semibold);
}

h3,
.text-h3 {
    font-size: 18px;
    font-weight: var(--font-weight-semibold);
}

.text-body {
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
}

.text-small {
    font-size: var(--font-size-small);
}

.text-xs {
    font-size: var(--font-size-xs);
}

.text-muted {
    color: var(--muted);
}

.text-semibold {
    font-weight: var(--font-weight-semibold);
}

.text-bold {
    font-weight: var(--font-weight-bold);
}

/* ============================================
   4. LAYOUT SYSTEM
   ============================================ */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.page {
    flex: 1;
    padding: var(--space-lg) var(--space-md);
    padding-bottom: 90px;
    /* Space for bottom nav on mobile */
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-md);
}

.grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Flexbox Utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.items-end {
    align-items: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-xs {
    gap: var(--space-xs);
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

.gap-xl {
    gap: var(--space-xl);
}

/* ============================================
   5. COMPONENTS - CARDS
   ============================================ */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--line);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card-sm {
    padding: var(--space-md);
}

.card-lg {
    padding: var(--space-xl);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.card-hero {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-700));
    color: white;
    border: none;
}

.card-accent {
    background: var(--color-accent-500);
    border-color: var(--color-accent);
}

.card-flat {
    box-shadow: none;
    border: 1px solid var(--line);
}

/* ============================================
   6. COMPONENTS - BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-semibold);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    /* Touch target */
    text-align: center;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

/* Primary Button */
.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-600);
    box-shadow: var(--shadow-medium);
}

.btn-primary:disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Secondary / Ghost Button */
.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
    background: rgba(13, 107, 62, 0.05);
}

/* Accent Button */
.btn-accent {
    background: var(--color-accent);
    color: var(--text);
}

.btn-accent:hover {
    background: var(--color-accent-600);
}

/* Danger Button */
.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #D93D3D;
}

/* Button Sizes */
.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-small);
    min-height: 36px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    min-height: 52px;
}

/* Icon Button */
.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-full);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 90px;
    right: var(--space-lg);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-strong);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    z-index: 40;
}

.fab:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px rgba(13, 107, 62, 0.3);
}

/* ============================================
   7. COMPONENTS - FORMS & INPUTS
   ============================================ */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    color: var(--text);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-semibold);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: var(--font-size-body);
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.form-input::placeholder {
    color: var(--muted);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-error {
    color: var(--danger);
    font-size: var(--font-size-small);
    margin-top: var(--space-xs);
}

/* Checkbox & Radio */
.form-checkbox,
.form-radio {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* ============================================
   8. COMPONENTS - NAVIGATION
   ============================================ */

/* Bottom Navigation (Mobile) */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 68px;
    padding: var(--space-sm) var(--space-md);
    background: var(--surface);
    border-top: 1px solid var(--line);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-dropdown);
    box-shadow: 0 -4px 12px rgba(12, 30, 20, 0.04);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    color: var(--muted);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-md);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--line);
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
}

/* Mobile: Slide up from bottom */
@media (max-width: 600px) {
    .modal {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        animation: slideUpMobile var(--transition-base);
    }
}

/* ============================================
   12. COMPONENTS - TOASTS
   ============================================ */

.toast {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
    z-index: var(--z-toast);
    animation: slideUpToast var(--transition-base);
    max-width: 90%;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
}

/* ============================================
   13. UTILITY CLASSES
   ============================================ */

/* Spacing */
.m-0 {
    margin: 0;
}

.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.mb-xl {
    margin-bottom: var(--space-xl);
}

.p-sm {
    padding: var(--space-sm);
}

.p-md {
    padding: var(--space-md);
}

.p-lg {
    padding: var(--space-lg);
}

/* Text Alignment */
.text-left {
    text-align: left;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Display */
.block {
    display: block;
}

.inline-block {
    display: inline-block;
}

.hidden {
    display: none;
}

/* Width */
.w-full {
    width: 100%;
}

.w-auto {
    width: auto;
}

/* Colors */
.text-primary {
    color: var(--color-primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--muted);
}

.bg-primary {
    background: var(--color-primary);
}

.bg-surface {
    background: var(--surface);
}

.bg-accent {
    background: var(--color-accent-500);
}

/* Borders */
.border {
    border: 1px solid var(--line);
}

.border-top {
    border-top: 1px solid var(--line);
}

.border-bottom {
    border-bottom: 1px solid var(--line);
}

/* Shadows */
.shadow-soft {
    box-shadow: var(--shadow-soft);
}

.shadow-medium {
    box-shadow: var(--shadow-medium);
}

.shadow-none {
    box-shadow: none;
}

/* Overflow */
.overflow-hidden {
    overflow: hidden;
}

.overflow-auto {
    overflow: auto;
}

.overflow-x-auto {
    overflow-x: auto;
}

/* Cursor */
.cursor-pointer {
    cursor: pointer;
}

/* ============================================
   14. ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUpMobile {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideUpToast {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-base);
}

.animate-slide-up {
    animation: slideUp var(--transition-base);
}

/* Hover Effects */
.hover-lift {
    transition: transform var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-6px);
}

.hover-scale {
    transition: transform var(--transition-fast);
}

.hover-scale:hover {
    transform: scale(1.02);
}

/* ============================================
        padding: var(--space-xl);
    }

    .fab {
        bottom: var(--space-xl);
    }

    .grid-md-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: > 1024px */
@media (min-width: 1025px) {
    .app-shell {
        flex-direction: row;
    }

    .sidebar {
        display: flex;
    }

    .bottom-nav {
        display: none;
    }

    .page {
        padding: var(--space-2xl) var(--space-xl);
        padding-bottom: var(--space-2xl);
    }

    .fab {
        display: none;
        /* Use sidebar actions on desktop */
    }

    .grid-lg-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-lg-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal {
        animation: slideUp var(--transition-slow);
    }

    .toast {
        bottom: var(--space-xl);
        left: var(--space-xl);
        transform: none;
    }
}

/* ============================================
   16. ACCESSIBILITY
   ============================================ */

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --line: #000000;
        --shadow-soft: none;
        --shadow-medium: none;
    }
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}