@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --font-display: 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    
    --color-primary: #0f766e;
    --color-primary-hover: #0d655d;
    --color-primary-light: #ccfbf1;
    
    --color-secondary: #64748b;
    --color-secondary-hover: #475569;
    
    --color-success: #16a34a;
    --color-success-bg: #dcfce7;
    --color-danger: #dc2626;
    --color-danger-bg: #fee2e2;
    --color-warning: #d97706;
    --color-warning-bg: #fef3c7;
    
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-light: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    font-family: var(--font-display);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(15, 118, 110, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(15, 118, 110, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

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

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

/* ============================================
   NAVBAR REFINADA
   ============================================ */
.navbar-custom {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-md);
    padding: 0.75rem 0;
}

.navbar-custom .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
    letter-spacing: -0.03em;
}

.navbar-custom .nav-pills {
    gap: 0.25rem;
}

.navbar-custom .nav-pills .nav-link {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.navbar-custom .nav-pills .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.navbar-custom .nav-pills .nav-link.active {
    color: #0f172a;
    background: var(--color-primary-light);
    font-weight: 600;
}

.navbar-custom .nav-link {
    color: rgba(255, 255, 255, 0.7);
    transition: color var(--transition-fast);
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

.navbar-custom .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.navbar-custom .nav-link i {
    font-size: 1.25rem;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.container-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

main {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border: 1px solid var(--color-border-light);
}

/* ============================================
   FORMULARIOS Y INPUTS
   ============================================ */
.form-control, .form-select {
    font-family: var(--font-display);
    font-size: 0.9rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
    outline: none;
}

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

.form-control:disabled, .form-select:disabled {
    background-color: #f1f5f9;
    color: var(--color-text-muted);
}

label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text);
    margin-bottom: 0.375rem;
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    font-family: var(--font-display);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: none;
    cursor: pointer;
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-secondary);
    color: #fff;
}

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

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

.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn i {
    font-size: 1.1em;
}

/* ============================================
   TABLAS
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
}

.table {
    margin-bottom: 0;
    font-size: 0.9rem;
    width: 100%;
    min-width: 900px;
}

.table thead th {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: #f8fafc;
    border-bottom: 2px solid var(--color-border);
    padding: 0.875rem 1rem;
    white-space: nowrap;
}

.table thead th.col-difference,
.table tbody td.col-difference {
    min-width: 160px;
    width: 160px;
    text-align: right;
}

.table thead th.col-precio,
.table tbody td.col-precio {
    min-width: 180px;
    width: 180px;
    text-align: left;
}

.table thead th.col-ticker,
.table tbody td.col-ticker {
    min-width: 180px;
    width: 180px;
    text-align: left;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border-light);
}

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

.table tbody tr:hover {
    background-color: #f8fafc;
}

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

/* ============================================
   CARDS Y BLOQUES
   ============================================ */
.card-stats {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.card-stats:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-stats.positive {
    border-left: 4px solid var(--color-success);
}

.card-stats.negative {
    border-left: 4px solid var(--color-danger);
}

/* ============================================
   SEARCH BOX / BORDER PANEL
   ============================================ */
.search-panel {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.search-panel .row {
    --bs-gutter-x: 1rem;
    row-gap: 0.75rem;
}

/* ============================================
   MODALES
   ============================================ */
.modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1.25rem 1.5rem;
    border-bottom: none;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-header .btn-close {
    filter: invert(1);
    opacity: 0.7;
}

.modal-header .btn-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border-light);
    background: #f8fafc;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============================================
   FORMULARIOS EN MODALES
   ============================================ */
.popup-form .row {
    margin-bottom: 1rem;
}

.popup-form .row > div:first-child {
    padding-right: 0;
}

.popup-form label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    padding-top: 0.5rem;
}

.popup-form .form-control, 
.popup-form .form-select {
    width: 100%;
}

/* ============================================
   RADIO BUTTONS Y CHECKBOX
   ============================================ */
.form-check {
    display: inline-flex;
    align-items: center;
    margin-right: 1rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    margin-right: 0.5rem;
    border: 2px solid var(--color-border);
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.form-check-label {
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
}

.form-switch .form-check-input {
    width: 2.5rem;
    height: 1.25rem;
}

/* ============================================
   INDICADORES DE GANANCIA/PÉRDIDA
   ============================================ */
.profit-positive {
    background-color: var(--color-success-bg) !important;
    color: #166534;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.profit-negative {
    background-color: var(--color-danger-bg) !important;
    color: #991b1b;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* ============================================
   TOTALES Y LABELS ESPECIALES
   ============================================ */
.total-label {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    text-align: center;
}

.total-label.positive {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.total-label.negative {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

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

main {
    animation: fadeIn 0.3s ease-out;
}

.table tbody tr {
    animation: fadeIn 0.2s ease-out;
    animation-fill-mode: both;
}

.table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.table tbody tr:nth-child(2) { animation-delay: 0.04s; }
.table tbody tr:nth-child(3) { animation-delay: 0.06s; }
.table tbody tr:nth-child(4) { animation-delay: 0.08s; }
.table tbody tr:nth-child(5) { animation-delay: 0.1s; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991px) {
    .navbar-custom .nav-pills {
        flex-wrap: wrap;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
    
    .navbar-custom .nav-pills .nav-link {
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (max-width: 767px) {
    .container-main {
        padding: 1rem;
    }
    
    main {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }
    
    .search-panel {
        padding: 1rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.625rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-stats {
        padding: 0.875rem 1rem;
    }
}

/* ============================================
   UTILIDADES
   ============================================ */
.text-mono {
    font-family: var(--font-mono);
}

.text-muted {
    color: var(--color-text-muted) !important;
}

.border-subtle {
    border: 1px solid var(--color-border-light) !important;
}

.bg-subtle {
    background-color: #f8fafc !important;
}

/* Checkbox readonly */
input[type="checkbox"][disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}
