:root {
    --bg-body: #0f111a;
    --bg-surface: rgba(30, 32, 47, 0.7);
    --bg-card: #1e202f;
    --bg-card-hover: #272a3b;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
    --font-main: 'Inter', sans-serif;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    font-family: var(--font-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    /* Optional: Subtle gradient background mesh */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 20%);
}

.app-container {
    display: flex;
    height: 100%;
}

/* Glassmorphism Utility */
.glass {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--glass-border);
}

/* Sidebar */
.sidebar {
    width: 80px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    z-index: 10;
}

.logo-area {
    margin-bottom: 40px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    padding: 0 10px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 12px 0;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-primary);
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Header */
.top-bar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.view-tag {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 44px;
    border-radius: 12px;
    width: 300px;
}

.search-box i {
    color: var(--text-secondary);
    margin-right: 10px;
}

.search-box input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
    font-family: var(--font-main);
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    height: 44px;
    padding: 0 24px;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-main);
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
}

/* Switch */
.switch-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-card);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.label-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Kanban Board */
.board-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 40px 40px 40px;
    /* Right left bottom padding */
    display: flex;
    gap: 24px;
    /* Custom Scrollbar for horizontal scrolling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.column {
    min-width: 320px;
    width: 320px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    height: 100%;
}

.column-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.column-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 6px;
}

.column-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.column-total {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.column-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Cards */
.deal-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.deal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

.deal-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.card-price {
    font-size: 13px;
    color: var(--success);
    font-weight: 600;
    margin-bottom: 12px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-info {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.owner-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #555;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    width: 600px;
    max-width: 90%;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    /* Limitar altura */
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* Header fijo */
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    /* Scroll interno solo aquí */
    flex: 1;
    /* Ocupa todo el espacio disponible */
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

/* ... resto de estilos ... */

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

input,
select,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-primary);
}

.section-divider {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin: 30px 0 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 5px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: auto;
    /* Empujar al fondo */
    padding-top: 20px;
    /* Separación visual */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    /* Línea divisoria sutil */
    background: var(--bg-card);
    /* Fondo sólido para que no se mezcle */
    position: sticky;
    /* Opcional: Pegajoso al fondo si está dentro del body */
    bottom: -24px;
    /* Compensar padding del body si es sticky */
    margin-left: -24px;
    /* Compensar padding del body */
    margin-right: -24px;
    padding: 20px 24px;
    /* Re-aplicar padding */
    z-index: 5;
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    height: 44px;
    padding: 0 24px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 500;
}

.btn-secondary:hover {
    color: white;
    border-color: white;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-secondary);
}

/* --- MOBILE / RESPONSIVE STYLES --- */
@media (max-width: 768px) {

    /* 1. Layout Principal */
    .app-container {
        flex-direction: column;
    }

    /* 2. Barra de Navegación (Bottom Nav) */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        flex-direction: row;
        padding: 0;
        background: rgba(30, 32, 47, 0.95);
        /* Menos transparencia para legibilidad */
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-right: none;
        justify-content: space-around;
        order: 10;
        /* Al final */
        z-index: 100;
        /* Por encima de todo */
    }

    .logo-area,
    .user-profile,
    .section-divider-nav {
        display: none !important;
    }

    .nav-menu {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        width: 100%;
        padding: 0;
    }

    .nav-item {
        flex: 1;
        padding: 8px 0;
        border-radius: 0;
    }

    .nav-item i {
        font-size: 24px;
        margin-bottom: 2px;
    }

    .nav-item span {
        font-size: 10px;
    }

    /* 3. Contenido Principal */
    .main-content {
        height: calc(100vh - 70px);
        /* Restar altura del navbar */
    }

    /* 4. Encabezado (Top Bar) */
    .top-bar {
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        padding: 15px 20px;
        gap: 15px;
    }

    .header-title h1 {
        font-size: 20px;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .search-box {
        width: 100%;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .switch-filter {
        align-self: flex-start;
        margin-bottom: 5px;
    }

    /* 5. Kanban Board Móvil */
    .board-container {
        padding: 10px 15px;
        gap: 15px;
        /* Snap Scroll para columnas */
        scroll-snap-type: x mandatory;
    }

    .column {
        min-width: 85vw;
        /* Casi pantalla completa */
        width: 85vw;
        scroll-snap-align: center;
        height: calc(100% - 10px);
    }

    /* 6. Modales en Móvil */
    .modal {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-body {
        padding: 15px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .modal-actions {
        padding: 15px;
        position: sticky;
        bottom: 0;
    }

    /* 7. Tablas (Contactos) */
    #contactsView {
        padding: 15px;
        overflow-y: auto;
    }

    .table-container {
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 8px;
    }

    /* Ocultar columnas menos importantes en móvil */
    .data-table th:nth-child(3),
    .data-table td:nth-child(3),
    /* Email */
    .data-table th:nth-child(5),
    .data-table td:nth-child(5)

    /* Proyectos */
        {
        display: none;
    }
}