/* =============================================
   CINCO LAGOS - Calculadora de Presupuesto
   ============================================= */

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e2f44;
    --accent: #27ae60;
    --accent-hover: #219a52;
    --danger: #e74c3c;
    --warning: #f39c12;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dce1e6;
    --input-bg: #f8f9fa;
    --sidebar-w: 260px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ===== LOGIN ===== */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h1 {
    text-align: center;
    color: var(--primary);
    font-size: 28px;
    margin-bottom: 8px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
    display: none;
}

/* ===== PRODUCT SELECTOR ===== */
#product-screen {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.product-selector {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    width: 600px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.product-selector h1 {
    text-align: center;
    color: var(--primary);
    font-size: 24px;
    margin-bottom: 8px;
}

.product-selector .subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 32px;
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.product-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.product-card:hover {
    border-color: var(--primary-light);
    background: #eaf2f8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.product-card .product-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.product-card .product-info h3 {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 4px;
}

.product-card .product-info p {
    font-size: 13px;
    color: var(--text-light);
}

.product-logout {
    text-align: center;
    margin-top: 24px;
}

.product-logout a {
    color: var(--text-light);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}

.product-logout a:hover {
    color: var(--danger);
}

.user-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 24px;
}

.user-badge.admin {
    background: #fdebd0;
    color: #e67e22;
}

.user-badge.user {
    background: #d5f5e3;
    color: #27ae60;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group { flex: 1; }

/* Input with addon */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group input {
    border-radius: 8px 0 0 8px;
    border-right: none;
}

.input-group .addon {
    padding: 10px 14px;
    background: var(--primary-dark);
    color: white;
    font-size: 13px;
    font-weight: 600;
    border-radius: 0 8px 8px 0;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.readonly-field {
    background: #e8f4fd !important;
    font-weight: 600;
    color: var(--primary) !important;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
}

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

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

.btn-accent:hover { background: var(--accent-hover); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

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

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

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

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

/* ===== APP LAYOUT ===== */
#app-screen { display: none; }

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary-dark);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-header .product-name {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
}

.sidebar-header .user-info {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    padding: 16px 20px 8px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item.admin-only {
    color: rgba(255,200,100,0.7);
}

.nav-item.admin-only.active {
    border-left-color: var(--warning);
    color: #f9e79f;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    gap: 8px;
}

.sidebar-footer .btn {
    flex: 1;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    padding: 8px;
}

.sidebar-footer .btn:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar-footer .btn.btn-logout:hover {
    background: rgba(231,76,60,0.8);
    color: white;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    color: var(--primary-dark);
}

.page-header p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease-out;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg);
}

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }

/* ===== RESULTS ===== */
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--bg);
}

.result-row:last-child { border-bottom: none; }

.result-label {
    font-size: 14px;
    color: var(--text-light);
}

.result-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.result-value.highlight { color: var(--primary); font-size: 20px; }
.result-value.accent { color: var(--accent); }
.result-value.danger { color: var(--danger); }

.result-box {
    display: block;
    text-align: center;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
}

/* ===== BADGES ===== */
.info-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.info-badge.cancelatorio { background: #fdebd0; color: #e67e22; }
.info-badge.financiado { background: #d5f5e3; color: #27ae60; }

.grupo-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.grupo-badge.anular { background: #f5eef8; color: #8e44ad; }
.grupo-badge.central { background: #eaf2f8; color: #2980b9; }
.grupo-badge.boulevard { background: #fef9e7; color: #f39c12; }
.grupo-badge.lagos, .grupo-badge.lago { background: #d5f5e3; color: #27ae60; }

/* ===== TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--primary-dark);
    color: white;
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.data-table tr:hover td { background: #eaf2f8; }
.data-table tr.selected td { background: #d4efdf; font-weight: 600; }

.data-table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ===== SEARCH ===== */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-light);
}

.search-bar select {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    min-width: 180px;
}

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== DISCLAIMER ===== */
.disclaimer {
    background: #fef9e7;
    border: 1px solid #f9e79f;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 12px;
    color: #7d6608;
    margin-top: 16px;
}

/* ===== DEPOSITO STATUS ===== */
.dep-status {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    margin-top: 8px;
}

.dep-status.suficiente { background: #d5f5e3; color: #27ae60; }
.dep-status.insuficiente { background: #fadbd8; color: #e74c3c; }

/* ===== TALON ===== */
.talon-container { max-width: 800px; margin: 0 auto; }

.talon-header {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    border-radius: 12px 12px 0 0;
}

.talon-body {
    padding: 24px;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
}

.talon-section { margin-bottom: 20px; }

.talon-section h3 {
    font-size: 14px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg);
}

/* ===== CARATULA ===== */
.caratula-header {
    text-align: center;
    padding: 20px;
    background: var(--primary-dark);
    color: white;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* ===== ADMIN ===== */
.admin-card {
    border-left: 4px solid var(--warning);
}

.admin-card .card-title {
    color: #e67e22;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg);
}

.config-item:last-child { border-bottom: none; }

.config-item label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.config-item input {
    width: 200px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    text-align: right;
}

.config-item input:focus {
    outline: none;
    border-color: var(--warning);
    box-shadow: 0 0 0 3px rgba(243,156,18,0.15);
}

.config-item .config-unit {
    font-size: 12px;
    color: var(--text-light);
    min-width: 60px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Lot price editor */
.lot-edit-row {
    display: grid;
    grid-template-columns: 100px 1fr 120px 200px;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg);
}

.lot-edit-row input {
    padding: 6px 10px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    text-align: right;
}

.lot-edit-row input:focus {
    outline: none;
    border-color: var(--warning);
}

/* ===== TOTAL BOX ===== */
.total-box {
    margin-top: 20px;
    padding: 20px;
    background: var(--primary-dark);
    border-radius: 10px;
    text-align: center;
}

.total-box .total-label {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    margin-bottom: 4px;
}

.total-box .total-value {
    color: white;
    font-size: 32px;
    font-weight: 700;
}

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

/* ===== PRINT ===== */
@media print {
    .sidebar, .page-header, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .talon-container { max-width: 100%; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr; }
    .admin-stats { grid-template-columns: 1fr 1fr; }
}
