/* ============================================================
   StockVault — Global Base Styles
   ============================================================ */

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

/* ──────────────────────────────────────────────
   CSS Custom Properties (Design Tokens)
   ────────────────────────────────────────────── */
:root {
    /* Brand */
    --color-primary:       #0B1F4D;
    --color-accent:        #2563EB;
    --color-accent-hover:  #1D4ED8;
    --color-accent-light:  #EEF5FF;
    --color-royal:         #1769E0;

    /* Feedback */
    --color-success:       #16A34A;
    --color-success-bg:    #F0FDF4;
    --color-danger:        #DC2626;
    --color-danger-bg:     #FEF2F2;
    --color-warning:       #D97706;
    --color-warning-bg:    #FFFBEB;
    --color-info:          #0EA5E9;
    --color-info-bg:       #F0F9FF;

    /* Neutrals */
    --color-text:          #111827;
    --color-text-muted:    #6B7280;
    --color-text-light:    #9CA3AF;
    --color-border:        #E5E7EB;
    --color-border-light:  #F3F4F6;
    --color-bg:            #F8FAFC;
    --color-surface:       #FFFFFF;

    /* Chart palette */
    --chart-1: #2563EB;
    --chart-2: #7C3AED;
    --chart-3: #059669;
    --chart-4: #DC2626;
    --chart-5: #D97706;
    --chart-6: #6B7280;
    --chart-7: #0EA5E9;
    --chart-8: #DB2777;

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

    /* Radius */
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  20px;
    --radius-xl:  28px;
    --radius-full: 9999px;

    /* Shadow */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.10);
    --shadow-card:0 2px 12px rgba(11,31,77,0.06);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:   'JetBrains Mono', 'Fira Mono', monospace;

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow:   350ms ease;
}

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

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

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--color-accent-hover); }

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

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

ul, ol { list-style: none; }

/* ──────────────────────────────────────────────
   Typography Scale
   ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.375rem, 3vw, 1.875rem); }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.375rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

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

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fw-900 { font-weight: 900; }

/* ──────────────────────────────────────────────
   Layout Utilities
   ────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-sm        { gap: var(--space-sm); }
.gap-md        { gap: var(--space-md); }
.gap-lg        { gap: var(--space-lg); }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }

.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); }

/* ──────────────────────────────────────────────
   Card Component
   ────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border-light);
    padding: var(--space-lg);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* ──────────────────────────────────────────────
   Buttons
   ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.btn:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.btn-secondary {
    background: var(--color-border-light);
    color: var(--color-text);
}
.btn-secondary:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover {
    background: #B91C1C;
    color: #fff;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}
.btn-success:hover {
    background: #15803D;
    color: #fff;
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

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

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    aspect-ratio: 1;
}

/* ──────────────────────────────────────────────
   Form Elements
   ────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9375rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control::placeholder {
    color: var(--color-text-light);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 36px;
}

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

.form-hint {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.form-error {
    font-size: 0.8125rem;
    color: var(--color-danger);
}

/* ──────────────────────────────────────────────
   Tables
   ────────────────────────────────────────────── */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--color-border-light);
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

thead th.text-right { text-align: right; }
thead th.text-center { text-align: center; }

tbody tr {
    border-bottom: 1px solid var(--color-border-light);
    transition: background-color var(--transition-fast);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background-color: var(--color-accent-light); }

tbody td {
    padding: 14px 16px;
    vertical-align: middle;
}

tbody td.text-right { text-align: right; }
tbody td.text-center { text-align: center; }

/* ──────────────────────────────────────────────
   Return Badge
   ────────────────────────────────────────────── */
.return-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.return-badge.positive {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.return-badge.negative {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.return-badge.neutral {
    color: var(--color-text-muted);
    background: var(--color-border-light);
}

/* ──────────────────────────────────────────────
   Badges / Tags
   ────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-blue    { background: var(--color-accent-light); color: var(--color-accent); }
.badge-green   { background: var(--color-success-bg);   color: var(--color-success); }
.badge-red     { background: var(--color-danger-bg);    color: var(--color-danger); }
.badge-yellow  { background: var(--color-warning-bg);   color: var(--color-warning); }
.badge-gray    { background: var(--color-border-light); color: var(--color-text-muted); }

.demo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid rgba(217,119,6,0.2);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* ──────────────────────────────────────────────
   Alert / Announcement
   ────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    border-left: 4px solid transparent;
}

.alert-information { background: var(--color-info-bg);    border-color: var(--color-info);    color: #075985; }
.alert-success     { background: var(--color-success-bg); border-color: var(--color-success); color: #166534; }
.alert-warning     { background: var(--color-warning-bg); border-color: var(--color-warning); color: #92400E; }
.alert-important   { background: var(--color-danger-bg);  border-color: var(--color-danger);  color: #991B1B; }

/* ──────────────────────────────────────────────
   Modal
   ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,31,77,0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.98);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-border-light);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 1.25rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    display: flex;
    align-items: center;
}

.modal-close:hover {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.modal-body {
    padding: var(--space-xl);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--color-border-light);
}

/* ──────────────────────────────────────────────
   Toast Notifications
   ────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px;
    min-width: 300px;
    max-width: 420px;
    pointer-events: all;
    border-left: 4px solid var(--color-accent);
    animation: toastIn 0.3s ease forwards;
    font-size: 0.9rem;
    font-weight: 500;
}

.toast.toast-success { border-color: var(--color-success); }
.toast.toast-error   { border-color: var(--color-danger); }
.toast.toast-warning { border-color: var(--color-warning); }
.toast.toast-info    { border-color: var(--color-info); }

.toast.toast-exit { animation: toastOut 0.3s ease forwards; }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error   .toast-icon { color: var(--color-danger); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info    .toast-icon { color: var(--color-info); }

.toast-msg { flex: 1; color: var(--color-text); }

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 1rem;
    padding: 2px;
    line-height: 1;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100px); }
}

/* ──────────────────────────────────────────────
   Skeleton Loaders
   ────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    display: block;
}

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

.skeleton-text  { height: 14px; margin: 6px 0; }
.skeleton-title { height: 20px; width: 60%; margin: 6px 0; }
.skeleton-kpi   { height: 80px; border-radius: var(--radius-lg); }
.skeleton-chart { height: 300px; border-radius: var(--radius-lg); }

/* ──────────────────────────────────────────────
   Empty State
   ────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.4;
    color: var(--color-accent);
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.empty-state-text {
    font-size: 0.9rem;
    max-width: 360px;
    line-height: 1.6;
}

/* ──────────────────────────────────────────────
   Pagination
   ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    margin-top: var(--space-lg);
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.page-btn:hover    { border-color: var(--color-accent); color: var(--color-accent); }
.page-btn.active   { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ──────────────────────────────────────────────
   Login Page
   ────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-brand {
    background: linear-gradient(135deg, var(--color-primary) 0%, #1a3a7a 60%, #1769E0 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    top: -150px;
    right: -150px;
}

.login-brand::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    bottom: -80px;
    left: -80px;
}

.login-brand-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    position: relative;
    z-index: 1;
}

.login-brand-logo .logo-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.login-brand-headline {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
    margin-bottom: var(--space-md);
    position: relative;
    z-index: 1;
}

.login-brand-sub {
    text-align: center;
    opacity: 0.75;
    font-size: 0.9875rem;
    max-width: 360px;
    position: relative;
    z-index: 1;
}

.login-illustration {
    position: relative;
    z-index: 1;
    margin-top: var(--space-2xl);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    width: 100%;
    max-width: 340px;
}

.login-mini-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    backdrop-filter: blur(10px);
}

.login-mini-card .label {
    font-size: 0.7rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.login-mini-card .value {
    font-size: 1.125rem;
    font-weight: 700;
}

.login-mini-card.positive .value { color: #4ADE80; }
.login-mini-card.negative .value { color: #F87171; }

.login-form-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    background: var(--color-surface);
}

.login-form-box {
    width: 100%;
    max-width: 400px;
}

.login-form-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: var(--space-xs);
}

.login-form-subtitle {
    color: var(--color-text-muted);
    margin-bottom: var(--space-xl);
    font-size: 0.9375rem;
}

.login-form-footer {
    margin-top: var(--space-md);
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* ──────────────────────────────────────────────
   Utility / Misc
   ────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--color-border-light);
    margin: var(--space-lg) 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }

/* ──────────────────────────────────────────────
   Responsive Breakpoints
   ────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 992px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-form-panel { padding: var(--space-xl) var(--space-md); }
}

@media (max-width: 768px) {
    :root { --space-lg: 16px; --space-xl: 24px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .card { padding: var(--space-md); }
    .modal { max-width: 100%; border-radius: var(--radius-lg); }
    #toast-container { left: 20px; right: 20px; top: auto; bottom: 20px; }
    .toast { min-width: unset; max-width: 100%; }
}

@media (max-width: 576px) {
    .btn { padding: 9px 16px; font-size: 0.8125rem; }
    h1 { font-size: 1.5rem; }
}
