/* ═══════════════════════════════════════════════════════════════
   SyncAEveryThing Document System — Global Design System
   Vanilla CSS · No Frameworks · Premium Dark/Light Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
    /* Sidebar / Dark Theme */
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-bg-active: rgba(16, 185, 129, 0.12);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-text-active: #10b981;
    --sidebar-border: rgba(148, 163, 184, 0.1);
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 0px;

    /* Content / Light Theme */
    --content-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --card-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Primary Colors */
    --primary: #10b981;
    --primary-light: #d1fae5;
    --primary-dark: #059669;

    /* Accent Colors for Document Types */
    --accent-quotation: #3b82f6;
    --accent-quotation-light: #dbeafe;
    --accent-billing: #8b5cf6;
    --accent-billing-light: #ede9fe;
    --accent-receipt: #f59e0b;
    --accent-receipt-light: #fef3c7;

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-placeholder: #cbd5e1;

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Borders & Dividers */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --divider: #e2e8f0;

    /* Typography */
    --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Bai Jamjuree', 'Sarabun', sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-Index System */
    --z-sidebar: 100;
    --z-overlay: 90;
    --z-sticky: 50;
    --z-modal: 200;
}

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

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

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--content-bg);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
    outline: none;
}

input, select, textarea {
    font-family: inherit;
    outline: none;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ── Layout Grid: Sidebar + Content ──────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.app-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: var(--space-lg);
    transition: margin-left var(--transition-base);
    width: calc(100% - var(--sidebar-width));
}

/* ── Typography Utilities ────────────────────────────────────── */
.font-heading {
    font-family: var(--font-heading);
}

.font-body {
    font-family: var(--font-body);
}

.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }
.text-3xl { font-size: 34px; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ── Card Component ──────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    padding: var(--space-lg);
}

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

.card-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

/* ── Badge / Tag ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-info {
    background: var(--accent-quotation-light);
    color: var(--accent-quotation);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-warning {
    background: var(--accent-receipt-light);
    color: var(--accent-receipt);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ── Button System ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-dark {
    background: var(--sidebar-bg);
    color: white;
}

.btn-dark:hover {
    background: #1a2744;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--content-bg);
    border-color: var(--text-muted);
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 11px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

/* ── Custom Scrollbar ────────────────────────────────────────── */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--text-placeholder);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-fadeInLeft {
    animation: fadeInLeft 0.35s ease-out;
}

/* ── Utility Classes ─────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.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); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.hidden { display: none !important; }
.block { display: block; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }
.cursor-pointer { cursor: pointer; }

.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); }
.pt-sm { padding-top: var(--space-sm); }
.pt-md { padding-top: var(--space-md); }
.pb-md { padding-bottom: var(--space-md); }

.space-y-sm > * + * { margin-top: var(--space-sm); }
.space-y-md > * + * { margin-top: var(--space-md); }
.space-y-lg > * + * { margin-top: var(--space-lg); }

/* ── Responsive Breakpoints ──────────────────────────────────── */
@media (max-width: 1023px) {
    .app-content {
        margin-left: 0;
        width: 100%;
        padding: var(--space-md);
    }
}

@media (max-width: 767px) {
    .app-content {
        padding: var(--space-sm) var(--space-md);
        padding-bottom: 80px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    .app-content {
        padding-bottom: 80px !important;
    }
}

/* ── Mobile Optimization Utilities (Mobile First) ────────────── */
@media (max-width: 640px) {
    .card {
        padding: var(--space-md) !important;
    }
    
    .form-section {
        padding: var(--space-sm) !important;
    }

    .flex-responsive {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .flex-responsive > select,
    .flex-responsive > button,
    .flex-responsive > input {
        width: 100% !important;
        flex: none !important;
    }

    .card-header .search-input-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
        margin-bottom: var(--space-sm);
    }

    .card-header .flex {
        width: 100% !important;
        justify-content: space-between;
    }

    .card-header .flex button {
        flex: 1;
        text-align: center;
    }
}

