@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #05126e;
    --primary-container: #222d83;
    --on-primary: #ffffff;
    --inverse-primary: #bcc2ff;
    --secondary-color: #984800;
    --secondary-container: #fd7c00;
    --on-secondary: #ffffff;
    --accent-color: #3d4db8;
    --tertiary-color: #001171;
    --tertiary-container: #152896;
    --success-color: #10b981;
    --danger-color: #ba1a1a;
    --warning-color: #fd7c00;
    --info-color: #3d4db8;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --surface-dim: #d9dadb;
    --surface-variant: #e1e3e4;
    --surface-muted: #e9ecef;
    --on-surface: #191c1d;
    --on-surface-variant: #454651;
    --text-main: #1a1d23;
    --outline-color: #c6c5d3;
    --border-color: #e9ecef;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --radius-sm: 0.25rem;
    --radius-default: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--background-color);
}

.navbar {
    background-color: var(--primary-color);
    color: var(--on-primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand a {
    color: var(--on-primary);
    text-decoration: none;
    font-family: 'Hanken Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--on-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: var(--on-primary);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-default);
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.user-name {
    color: white;
}

.btn-logout {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.3s;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .nav-menu {
        position: fixed;
        top: 60px;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: calc(100vh - 60px);
        background-color: var(--primary-color);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        transition: right 0.3s ease;
        overflow-y: auto;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-link {
        width: 100%;
        text-align: left;
    }

    .nav-user {
        flex-direction: column;
        align-items: stretch;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding-top: 1rem;
        margin-top: 1rem;
        padding-left: 0;
        margin-left: 0;
    }

    .btn-logout {
        width: 100%;
        text-align: center;
    }
}

.main-content {
    max-width: 1200px;
    margin: 2.5rem auto;
    padding: 0 24px;
    min-height: calc(100vh - 200px);
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-default);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid transparent;
}

.alert i {
    font-size: 1.25rem;
}

.alert-block {
    align-items: flex-start;
}

.alert-block > div {
    flex: 1;
    line-height: 1.5;
}

.alert-block br {
    display: block;
    margin-bottom: 0.25rem;
    content: "";
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
    color: #065f46;
}

.alert-error {
    background-color: rgba(186, 26, 26, 0.08);
    border-color: rgba(186, 26, 26, 0.2);
    color: #93000a;
}

.alert-warning {
    background-color: rgba(253, 124, 0, 0.08);
    border-color: rgba(253, 124, 0, 0.2);
    color: #984800;
}

.alert-info {
    background-color: rgba(61, 77, 184, 0.08);
    border-color: rgba(61, 77, 184, 0.2);
    color: var(--primary-color);
}

h1, h2, h3, h4, h5, h6, .card-title, .card-header h2 {
    font-family: 'Hanken Grotesk', sans-serif;
    font-weight: 600;
    color: var(--primary-color);
}

.card {
    background: var(--surface-color);
    border-radius: var(--radius-default);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-default);
    cursor: pointer;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.5;
    transition: all 0.2s ease;
    text-align: center;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-primary:hover {
    background-color: var(--primary-container);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #1b5e1f;
}

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

.btn-danger:hover {
    background-color: #93000a;
}

.btn-info {
    background-color: var(--accent-color);
    color: white;
}

.btn-info:hover {
    background-color: var(--primary-container);
}

.btn-secondary {
    background-color: transparent;
    color: var(--on-surface-variant);
    border: 1.5px solid var(--outline-color);
}

.btn-secondary:hover {
    background-color: var(--surface-muted);
    border-color: var(--on-surface-variant);
}

.btn-small {
    padding: 0.4rem 0.7rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
    display: flex;
}

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

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--on-surface);
}

.form-label.required::after {
    content: " *";
    color: var(--danger-color);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--outline-color);
    border-radius: var(--radius-default);
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--on-surface);
    background-color: var(--surface-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    border-width: 2px;
    box-shadow: 0 0 0 4px rgba(5, 18, 110, 0.08);
}

.form-control:disabled {
    background-color: var(--surface-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-default);
    border: 1px solid var(--border-color);
}

/* Mobile Card Tables: en pantallas chicas cada fila se muestra como tarjeta */
@media (max-width: 768px) {
    .table-mobile-cards {
        overflow-x: visible;
        border: none;
        border-radius: 0;
    }

    .table-mobile-cards table {
        background: transparent;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td {
        display: block;
        width: 100%;
    }

    .table-mobile-cards tr {
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-default);
        box-shadow: var(--shadow-sm);
        margin-bottom: 1rem;
        padding: 0.5rem 0;
    }

    .table-mobile-cards tr:hover {
        background-color: var(--surface-color);
    }

    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: 0.6rem 1rem;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
    }

    .table-mobile-cards td:last-child {
        border-bottom: none;
    }

    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.8125rem;
        color: var(--on-surface-variant);
        text-align: left;
        flex-shrink: 0;
    }

    .table-mobile-cards td[data-label=""]::before {
        display: none;
    }

    .table-mobile-cards td.td-actions {
        justify-content: stretch;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .table-mobile-cards td.td-actions::before {
        display: none;
    }

    .table-mobile-cards td.td-actions .btn {
        flex: 1;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-color);
    font-size: 0.9375rem;
}

table th {
    background-color: var(--primary-color);
    color: var(--on-primary);
    padding: 0.875rem 1rem;
    text-align: left;
    font-family: 'Hanken Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--on-surface);
}

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

table tr:hover {
    background-color: var(--surface-container-low);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.12);
    color: #065f46;
}

.badge-warning {
    background-color: rgba(253, 124, 0, 0.12);
    color: #984800;
}

.badge-danger {
    background-color: rgba(186, 26, 26, 0.12);
    color: #93000a;
}

.badge-info {
    background-color: rgba(61, 77, 184, 0.12);
    color: var(--primary-color);
}

.badge-secondary {
    background-color: var(--surface-muted);
    color: var(--on-surface-variant);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background-color: rgba(5, 18, 110, 0.08);
    color: var(--primary-color);
}

.stat-icon.success {
    background-color: rgba(16, 185, 129, 0.08);
    color: var(--success-color);
}

.stat-icon.warning {
    background-color: rgba(253, 124, 0, 0.08);
    color: var(--warning-color);
}

.stat-icon.danger {
    background-color: rgba(186, 26, 26, 0.08);
    color: var(--danger-color);
}

.stat-info h3 {
    font-family: 'Hanken Grotesk', sans-serif;
    font-size: 1.875rem;
    margin: 0;
    color: var(--on-surface);
}

.stat-info p {
    margin: 0;
    color: var(--on-surface-variant);
    font-size: 0.875rem;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.col {
    flex: 1;
    padding: 0 15px;
}

.col-2 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 0 15px;
}

.col-3 {
    flex: 0 0 33.3333%;
    max-width: 33.3333%;
    padding: 0 15px;
}

@media (max-width: 992px) {
    .col-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 768px) {
    .col-2,
    .col-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Login/Register Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 500px;
    width: 100%;
    padding: 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: #666;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Mobile Register Form */
@media (max-width: 768px) {
    .auth-container {
        align-items: flex-start;
        padding: 0;
        min-height: 100vh;
        overflow-y: auto !important;
        display: block;
    }
    
    .auth-card {
        margin: 0;
        padding: 1rem;
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        box-shadow: none;
    }
    
    .auth-header i {
        font-size: 2.5rem !important;
    }
    
    .register-form-mobile {
        overflow: visible;
    }

    .form-sections {
        display: flex;
        transition: transform 0.3s ease;
        overflow: visible;
    }

    .form-section {
        min-width: 100%;
        width: 100%;
        padding: 0;
        box-sizing: border-box;
    }

    .section-nav {
        display: flex;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .form-control {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

.footer {
    background-color: var(--inverse-surface);
    color: var(--inverse-on-surface);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 3rem;
    font-size: 0.875rem;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Field Builder */
.field-builder {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.field-item {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.field-item:hover {
    background: #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.field-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.field-item-header strong {
    color: var(--primary-color);
    font-size: 1rem;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 2rem;
}

/* Print Styles */
@media print {
    .navbar, .footer, .btn, .alert {
        display: none;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
}
