/* ==========================================================================
   CAMBIO BY OSOFT - PREMIUM STYLING SYSTEM (VANILLA CSS)
   ========================================================================== */

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

/* CSS Variables for Colors and Design Tokens */
:root {
    /* Light Theme Tokens */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Brand Accent Colors */
    --primary: #4f46e5;       /* Indigo */
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    
    --success: #10b981;       /* Emerald Green (Buy) */
    --success-light: rgba(16, 185, 129, 0.1);
    
    --danger: #ef4444;        /* Rose Red (Sell) */
    --danger-light: rgba(239, 68, 68, 0.1);
    
    --warning: #f59e0b;       /* Amber (Gold / Oro) */
    --warning-light: rgba(245, 158, 11, 0.1);
    
    --info: #06b6d4;          /* Cyan (Checks / Info) */
    --info-light: rgba(6, 182, 212, 0.1);
    
    /* Layout Tokens */
    --sidebar-width: 260px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

[data-theme="dark"] {
    /* Dark Theme Tokens */
    --bg-primary: #0b0f19;
    --bg-secondary: #131a2c;
    --bg-tertiary: #1e293b;
    --border-color: #2e3b52;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-light: rgba(99, 102, 241, 0.15);
    --primary: #6366f1;
    --primary-hover: #818cf8;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: var(--transition-base);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

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

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: var(--transition-base);
}

.glass-panel:hover {
    box-shadow: var(--shadow-lg);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

/* Navigation Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: var(--transition-base);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    padding-left: 0.5rem;
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 800;
    font-size: 1.25rem;
    font-family: 'Outfit', sans-serif;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sidebar-logo-text-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.sidebar-logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.02em;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-logo-subtext {
    font-size: 0.7rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-item i {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Theme Switcher */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.theme-toggle-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.theme-toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    position: relative;
    transition: var(--transition-base);
}

.theme-toggle-switch::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    top: 3px;
    left: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: var(--transition-base);
}

[data-theme="dark"] .theme-toggle-switch {
    background: var(--primary);
}

[data-theme="dark"] .theme-toggle-switch::before {
    left: 23px;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 2rem 3rem;
    max-width: 1600px;
    width: calc(100% - var(--sidebar-width));
}

/* Header & Tickers */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-title h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.ticker-container {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
}

.ticker-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.ticker-currency {
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.ticker-rates {
    display: flex;
    gap: 0.5rem;
}

.ticker-buy {
    color: var(--success);
}

.ticker-sell {
    color: var(--danger);
}

/* ==========================================================================
   DASHBOARD SECTION
   ========================================================================== */

/* Balance Overview Grid */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.balance-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.balance-card.total::before { background: var(--primary); }
.balance-card.ars::before { background: var(--info); }
.balance-card.usd::before { background: var(--success); }
.balance-card.eur::before { background: var(--primary); }
.balance-card.brl::before { background: #eab308; } /* BRL Yellow */
.balance-card.gold::before { background: var(--warning); } /* Gold Amber */

.balance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.balance-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.balance-card.total .balance-icon { background: var(--primary-light); color: var(--primary); }
.balance-card.ars .balance-icon { background: var(--info-light); color: var(--info); }
.balance-card.usd .balance-icon { background: var(--success-light); color: var(--success); }
.balance-card.eur .balance-icon { background: var(--primary-light); color: var(--primary); }
.balance-card.brl .balance-icon { background: rgba(234, 179, 8, 0.1); color: #eab308; }
.balance-card.gold .balance-icon { background: var(--warning-light); color: var(--warning); }

.balance-amount {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.balance-equivalent {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Analytics Row (Charts) */
.analytics-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.chart-card {
    padding: 1.5rem;
    height: 360px;
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.chart-container {
    flex-grow: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

/* Operations List & Tables */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.table-card {
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-tertiary);
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(0,0,0,0.01);
}

[data-theme="dark"] .data-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

/* Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge.income { background: var(--success-light); color: var(--success); }
.badge.expense { background: var(--danger-light); color: var(--danger); }
.badge.exchange { background: var(--primary-light); color: var(--primary); }

.badge.cartera { background: var(--info-light); color: var(--info); }
.badge.cobrado { background: var(--success-light); color: var(--success); }
.badge.endosado { background: rgba(107, 114, 128, 0.1); color: #6b7280; }
.badge.rechazado { background: var(--danger-light); color: var(--danger); }

/* ==========================================================================
   TRANSACTIONS SECTION
   ========================================================================== */
.form-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    align-items: start;
}

.form-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.form-tab {
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: var(--transition-fast);
}

.form-tab:hover {
    color: var(--text-primary);
}

.form-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.form-section {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-textarea {
    resize: vertical;
}

/* Exchange Rate Calculator visual representation */
.exchange-visual {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px dashed var(--border-color);
}

.exchange-side {
    text-align: center;
    flex: 1;
}

.exchange-side-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.exchange-side-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

.exchange-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 0 1rem;
}

/* Check attachment sub-form */
.check-toggle-container {
    background: var(--bg-tertiary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.subform-container {
    border-left: 3px solid var(--primary);
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
    display: none; /* Toggled via JS */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-full {
    width: 100%;
}

/* ==========================================================================
   CHECKS LEDGER & FILTERS
   ========================================================================== */
.filter-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
}

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    padding-left: 2.5rem;
}

/* Traceability Timeline */
.timeline {
    position: relative;
    padding-left: 1.5rem;
    border-left: 2px solid var(--border-color);
    margin-top: 1rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    left: -22px;
    top: 4px;
    border: 2px solid var(--bg-secondary);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.timeline-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.timeline-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-premium);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.modal-close {
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Check action buttons in tables */
.action-btn {
    padding: 0 0.45rem;
    white-space: nowrap;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.action-btn.btn-pay:hover {
    color: var(--success);
    background: var(--success-light);
    border-color: transparent;
}

.action-btn.btn-bounce:hover {
    color: var(--danger);
    background: var(--danger-light);
    border-color: transparent;
}

.action-btn.btn-trace:hover {
    color: var(--primary);
    background: var(--primary-light);
    border-color: transparent;
}

/* Quick transaction details in sidebar/right card */
.quick-summary-card {
    padding: 1.5rem;
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.5rem;
}

.summary-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.summary-label {
    color: var(--text-secondary);
}

.summary-value {
    font-weight: 600;
}

/* ==========================================================================
   UTILITY & SPA TABS
   ========================================================================== */
.view-section {
    display: none; /* Controlled by active class */
}

.view-section.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1024px) {
    .analytics-row {
        grid-template-columns: 1fr;
    }
    
    .form-layout {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    
    .sidebar-logo {
        margin-bottom: 1rem;
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .nav-item {
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem;
    }
    
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .filter-bar {
        grid-template-columns: 1fr;
    }
}
