/* ==========================================================================
   Variables y Reset General
   ========================================================================== */
:root {
    --primary: #1e3a8a;
    --primary-dark: #172554;
    --primary-light: #3b82f6;
    --accent: #0ea5e9;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    
    /* Estados de colaboradores */
    --status-disponible: #10b981;
    --status-trabajando: #f59e0b;
    --status-ocupado: #ef4444;
    --status-nodisponible: #64748b;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --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);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    font-size: 14px;
}

/* ==========================================================================
   Pantalla de Login
   ========================================================================== */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 440px;
    padding: 36px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.3);
    text-align: center;
}

.login-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
}

.login-logos img {
    height: 52px;
    object-fit: contain;
}

.login-card h2 {
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-card p.subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 24px;
}

.server-selector-container {
    margin-bottom: 20px;
    text-align: left;
}

.server-selector-container label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.server-selector-container select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #f1f5f9;
}

.form-group {
    margin-bottom: 18px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input,
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    background: #fff;
}

.input-with-icon input {
    padding-right: 40px;
}

.input-with-icon input:focus,
.form-input:focus,
textarea:focus,
select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.toggle-password:hover {
    color: var(--text-primary);
}

.btn-primary {
    width: 100%;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

/* ==========================================================================
   Layout Principal del Dashboard
   ========================================================================== */
#app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header img {
    height: 34px;
    max-width: 100px;
    object-fit: contain;
}

.sidebar-header .app-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    text-decoration: none;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

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

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #334155;
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    line-height: 1.3;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.user-info .role {
    font-size: 11px;
    color: var(--text-sidebar);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.btn-logout:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    min-height: 60px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    flex-shrink: 0;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.mobile-menu-toggle:hover {
    background: #f1f5f9;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Barra de navegación superior (Visible en móvil/pantallas angostas o como barra superior adaptable) */
.top-nav-bar {
    display: none;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
}

.top-nav-bar::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.top-nav-bar .nav-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f1f5f9;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s ease;
}

.top-nav-bar .nav-item:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.top-nav-bar .nav-item.active {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-role-badge {
    font-size: 11px;
    font-weight: 700;
    background: #e0f2fe;
    color: #0369a1;
    padding: 3px 8px;
    border-radius: 12px;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Responsive Breakpoints - Composable Layout para Móvil
   ========================================================================== */
@media (max-width: 900px) {
    #app-layout {
        flex-direction: column;
    }

    /* Ocultar barra lateral en móvil */
    .sidebar {
        display: none;
    }

    /* Mostrar barra horizontal superior con iconos y nombres */
    .top-nav-bar {
        display: flex;
        order: 3;
        width: 100%;
        border-top: 1px solid var(--border-color);
        padding-top: 8px;
    }

    .topbar {
        padding: 10px 16px;
    }

    .content-area {
        padding: 16px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .partida-add-row {
        grid-template-columns: 1fr 1fr;
    }

    .partida-add-row input:nth-child(2),
    .partida-add-row input:nth-child(3) {
        grid-column: span 2;
    }
}

.content-area {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
}

/* ==========================================================================
   Tab Content & Views
   ========================================================================== */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

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

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-success {
    background-color: #10b981;
    color: white;
}
.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #fee2e2;
    color: #dc2626;
}
.btn-danger:hover {
    background-color: #fca5a5;
}

.btn-icon-only {
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.btn-icon-only:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* Cards & Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

/* Dashboard Principal: Estado Admin & Calendario */
.dashboard-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
}

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

.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.status-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.status-btn {
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.status-btn.selected[data-status="DISPONIBLE"],
.status-pill.status-disponible {
    background-color: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.status-btn.selected[data-status="TRABAJANDO"],
.status-pill.status-trabajando {
    background-color: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.status-btn.selected[data-status="OCUPADO"],
.status-pill.status-ocupado {
    background-color: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.status-btn.selected[data-status="NO_DISPONIBLE"],
.status-pill.status-nodisponible {
    background-color: #f1f5f9;
    border-color: #64748b;
    color: #334155;
}

.status-pill {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* Calendar Card */
.calendar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px;
}

.citas-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 480px;
    overflow-y: auto;
}

.cita-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
}

.cita-time {
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
    min-width: 80px;
}

.cita-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.cita-title {
    flex: 1;
    margin: 0 16px;
    font-weight: 500;
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

th {
    background: #f8fafc;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13.5px;
    color: var(--text-primary);
    vertical-align: middle;
}

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

tr:hover td {
    background-color: #f8fafc;
}

/* Partidas / Items Table Builder in Cotizaciones & EDC */
.builder-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.partidas-box {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.partida-add-row {
    background: #f8fafc;
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 80px 1.5fr 1.5fr 120px 100px;
    gap: 10px;
    align-items: center;
}

.totals-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-top: 16px;
    gap: 8px;
    padding-right: 16px;
}

.total-row {
    display: flex;
    width: 260px;
    justify-content: space-between;
    font-size: 14px;
}

.total-row.grand-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

/* Service Card with Client Logo */
.service-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.client-logo-preview {
    height: 36px;
    max-width: 90px;
    object-fit: contain;
}

.badge-cobro {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-cobro.cobrado {
    background: #d1fae5;
    color: #065f46;
}
.badge-cobro.pendiente {
    background: #fee2e2;
    color: #991b1b;
}

/* ==========================================================================
   Modales Custom (NO ventanas emergentes nativas del navegador)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* Toast Notificaciones */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 3000;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.2s ease;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

