/* =============================================
   FORMULALAB 360 — DESIGN SYSTEM
   Premium Dark UI with Glassmorphism
   ============================================= */

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

/* ---------- Variables ---------- */
:root {
    --bg-base:        #060b14;
    --bg-dark:        #0a1020;
    --bg-card:        #111827;
    --text-main:      #f1f5f9;
    --text-muted:     #64748b;
    --text-sub:       #94a3b8;

    --primary:        #3b82f6;
    --primary-light:  #60a5fa;
    --primary-dark:   #2563eb;
    --primary-glow:   rgba(59, 130, 246, 0.25);

    --cyan:           #06b6d4;
    --cyan-glow:      rgba(6, 182, 212, 0.2);

    --accent:         #f59e0b;
    --accent-glow:    rgba(245, 158, 11, 0.2);

    --success:        #10b981;
    --success-glow:   rgba(16, 185, 129, 0.2);

    --danger:         #ef4444;
    --danger-glow:    rgba(239, 68, 68, 0.2);

    --purple:         #8b5cf6;
    --purple-glow:    rgba(139, 92, 246, 0.2);

    --border:         rgba(255, 255, 255, 0.06);
    --border-hover:   rgba(255, 255, 255, 0.12);

    --glass-bg:       rgba(10, 16, 32, 0.6);
    --glass-border:   rgba(255, 255, 255, 0.08);
    --glass-shine:    rgba(255, 255, 255, 0.04);

    --sidebar-w:      260px;
    --topbar-h:       68px;

    --gradient-primary: linear-gradient(135deg, var(--cyan) 0%, var(--primary) 100%);
    --gradient-bg:      radial-gradient(ellipse at top left, rgba(30, 27, 75, 0.8) 0%, var(--bg-base) 60%);

    --shadow-card:    0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow:    0 0 30px rgba(59, 130, 246, 0.15);

    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --radius-xl:   20px;

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background: var(--gradient-bg);
    background-color: var(--bg-base);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ---------- Layout ---------- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: rgba(6, 11, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Subtle gradient line on right edge */
.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: -1px;
    width: 1px; height: 100%;
    background: linear-gradient(180deg, transparent, var(--primary) 50%, transparent);
    opacity: 0.4;
}

.logo {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.logo i {
    width: 36px; height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    box-shadow: 0 0 16px var(--primary-glow);
    flex-shrink: 0;
}

.logo span {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    padding: 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-sub);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--glass-shine);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-light);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; height: 60%;
    width: 3px;
    background: var(--gradient-primary);
    border-radius: 0 2px 2px 0;
}

.user-profile {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile img {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-hover);
}

.user-info { display: flex; flex-direction: column; }
.user-info .name  { font-weight: 600; font-size: 0.85rem; }
.user-info .role  { font-size: 0.75rem; color: var(--text-muted); }

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-h);
    padding: 0 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(6, 11, 20, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-shrink: 0;
    z-index: 50;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    width: 280px;
    transition: all var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-bar i { color: var(--text-muted); font-size: 0.8rem; }

.search-bar input {
    background: none;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
    font-family: inherit;
    font-size: 0.875rem;
}

.search-bar input::placeholder { color: var(--text-muted); }

.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

/* ========== BUTTONS ========== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    box-shadow: 0 4px 14px var(--primary-glow);
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    filter: brightness(1.08);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--glass-bg);
    color: var(--text-sub);
    border: 1px solid var(--border);
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    font-family: inherit;
}

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { color: var(--text-main); background: var(--glass-shine); }

/* ========== CONTENT AREA ========== */
.content-wrapper {
    padding: 1.75rem;
    overflow-y: auto;
    flex: 1;
}

/* ========== PAGE HEADER ========== */
.dashboard-header {
    margin-bottom: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.page-subtitle { color: var(--text-muted); font-size: 0.875rem; }

/* ========== GLASS CARD ========== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

/* Top shine line */
.glass::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
}

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all var(--transition);
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.4), var(--shadow-glow);
    border-color: var(--border-hover);
}

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

.stat-info { display: flex; flex-direction: column; gap: 0.15rem; }

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* ========== DASHBOARD WIDGETS ========== */
.dashboard-widgets {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
}

.widget { padding: 1.5rem; }

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.widget-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========== QUICK ACTIONS ========== */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.quick-action-card {
    padding: 1.25rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-main);
    transition: all var(--transition);
    display: block;
}

.quick-action-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.quick-action-card i {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    display: block;
}

.quick-action-card h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.2rem; }
.quick-action-card p  { font-size: 0.78rem; color: var(--text-muted); }

/* ========== ACTIVITY LIST ========== */
.activity-list { display: flex; flex-direction: column; gap: 0.75rem; }

.activity-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

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

.activity-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--glass-shine);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.activity-details p   { font-size: 0.85rem; margin-bottom: 0.15rem; }
.activity-details span { font-size: 0.75rem; color: var(--text-muted); }

/* ========== FORM CONTROLS ========== */
.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(10, 16, 32, 0.5);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all var(--transition);
    outline: none;
    line-height: 1.5;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(10, 16, 32, 0.8);
}

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

select.form-control { cursor: pointer; }

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

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-sub);
    font-size: 0.8rem;
    font-weight: 500;
}

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

/* ========== TABLE ========== */
.table-container { width: 100%; overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table thead th {
    padding: 0.9rem 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: rgba(255,255,255,0.015);
}

.table tbody td {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.875rem;
}

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

.table tbody tr:hover { background: rgba(255,255,255,0.025); }
.table tbody tr:last-child td { border-bottom: none; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-default  { background: rgba(255,255,255,0.08);  color: var(--text-sub);   border: 1px solid var(--border); }
.badge-primary  { background: rgba(59,130,246,0.15);   color: #60a5fa;           border: 1px solid rgba(59,130,246,0.25); }
.badge-success  { background: rgba(16,185,129,0.15);   color: #34d399;           border: 1px solid rgba(16,185,129,0.25); }
.badge-warning  { background: rgba(245,158,11,0.15);   color: #fbbf24;           border: 1px solid rgba(245,158,11,0.25); }
.badge-danger   { background: rgba(239,68,68,0.15);    color: #f87171;           border: 1px solid rgba(239,68,68,0.25); }
.badge-purple   { background: rgba(139,92,246,0.15);   color: #a78bfa;           border: 1px solid rgba(139,92,246,0.25); }

/* ========== ALERTS ========== */
.alert {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.alert-danger  { background: var(--danger-glow);  border-left: 3px solid var(--danger);  color: #fca5a5; }
.alert-success { background: var(--success-glow); border-left: 3px solid var(--success); color: #6ee7b7; }
.alert-warning { background: var(--accent-glow);  border-left: 3px solid var(--accent);  color: #fcd34d; }

/* ========== FORMULA BUILDER ========== */
.formula-total-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.total-indicator {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
    border: 1px solid var(--border);
    background: var(--glass-bg);
    transition: all var(--transition);
}

.total-indicator.valid {
    color: var(--success);
    border-color: rgba(16,185,129,0.3);
    background: var(--success-glow);
    box-shadow: 0 0 12px var(--success-glow);
}

.total-indicator.invalid {
    color: var(--danger);
    border-color: rgba(239,68,68,0.3);
    background: var(--danger-glow);
}

/* ========== COST PANEL ========== */
.cost-box {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

.cost-box .label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.2rem; font-weight: 500; }
.cost-box .value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }

/* ========== PROJECT CARDS ========== */
.project-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all var(--transition);
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: var(--border-hover);
}

/* ========== STATUS PILLS ========== */
.status-conceptual   { color: var(--text-muted); border-color: rgba(100,116,139,0.3); background: rgba(100,116,139,0.1); }
.status-experimental { color: var(--accent);     border-color: rgba(245,158,11,0.3);  background: var(--accent-glow); }
.status-piloto       { color: var(--purple);     border-color: rgba(139,92,246,0.3);  background: var(--purple-glow); }
.status-validada     { color: var(--success);    border-color: rgba(16,185,129,0.3);  background: var(--success-glow); }
.status-produccion   { color: var(--primary-light); border-color: rgba(59,130,246,0.3); background: var(--primary-glow); }
.status-descartada   { color: var(--danger);     border-color: rgba(239,68,68,0.3);   background: var(--danger-glow); }

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

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content-wrapper { padding: 1rem; }
}
