* {
    box-sizing: border-box;
}

:root {
    /* --- SYNCORI FLOW LIGHT THEME --- */

    /* Global Colors */
    --accent-primary: #258cf4;
    /* Stitch Blue */
    --accent-secondary: #a855f7;
    /* Purple */
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    /* Backgrounds */
    --bg-body: #f1f5f9;
    /* Light Slate */
    --bg-sidebar: #ffffff;
    /* White */
    --bg-card: #ffffff;
    /* White */
    --bg-hover: #e2e8f0;
    /* Slate 200 */
    --bg-active: rgba(37, 140, 244, 0.1);
    /* Blue Tint */

    /* Text */
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #64748b;
    /* Slate 500 */
    --text-tertiary: #94a3b8;
    /* Slate 400 */
    --text-on-accent: #ffffff;

    /* Borders */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --glass-border: rgba(0, 0, 0, 0.05);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    background: var(--bg-body);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    margin: 0;

    /* Layout */
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    overflow: hidden;
    position: relative;
}

/* --- Header & Viewport --- */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-body);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    z-index: 20;
    position: relative;
}


/* --- Header Typography Fixes --- */
.title-group h1 {
    font-size: 20px;
    line-height: 1.2;
    margin: 0;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.title-group p {
    font-size: 13px;
    line-height: 1.4;
    margin-top: 2px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#app-viewport {
    flex: 1;
    overflow-y: auto;
    background: transparent;
    /* Ensure gray body shows through */
    position: relative;
    z-index: 1;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Components --- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.2sease;
}

/* Helper for "Glass" look - now just White in light theme */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 140, 244, 0.2);
}

.btn-primary:hover {
    background: #1d72ca;
    /* Darker blue */
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--text-tertiary);
    color: var(--text-primary);
    background: var(--bg-body);
}

.btn-icon-only {
    padding: 8px;
    width: 36px;
    height: 36px;
}

/* Inputs */
input,
select,
textarea {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 140, 244, 0.1);
}

/* --- Sidebar Specifics --- */
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-left: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin: 24px 0 8px 12px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

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

.nav-item i {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 24px;
}

/* --- Chat Specifics --- */
.chat-container {
    display: flex;
    height: 100%;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 75%;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
    position: relative;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-bubble.bot {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-meta {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.4);
    text-align: right;
    margin-top: 4px;
}

.chat-bubble.user .chat-meta {
    color: rgba(255, 255, 255, 0.7);
}

/* User Avatar */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: white;
}

/* Status Badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-Nuevo {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.status-Contactado {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.status-Calificado {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ede9fe;
}

.status-Interesado {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fef9c3;
}

.status-En-Negociacion {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}

.status-Cerrado {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #dcfce7;
}

.status-Perdido {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fee2e2;
}


/* Specific Utilities */
.text-success {
    color: var(--accent-success);
}

.text-warning {
    color: var(--accent-warning);
}

.text-danger {
    color: var(--accent-danger);
}

.bg-success-light {
    background: rgba(16, 185, 129, 0.1);
}

.bg-warning-light {
    background: rgba(245, 158, 11, 0.1);
}

.bg-danger-light {
    background: rgba(239, 68, 68, 0.1);
}

/* --- Conversations View --- */
/* --- Lead Snapshot Redesign --- */
.snapshot-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

.snapshot-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.snapshot-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.snapshot-property-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.property-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.property-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-stepper {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-top: 32px;
    margin-bottom: 12px;
    padding: 0 10px;
}

.progress-stepper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10px;
    right: 10px;
    height: 3px;
    background: var(--border-color);
    z-index: 1;
    transform: translateY(-50%);
}

.stepper-line-active {
    position: absolute;
    top: 50%;
    left: 10px;
    height: 3px;
    background: var(--accent-primary);
    z-index: 2;
    transform: translateY(-50%);
    transition: width 0.4s ease;
}

.step-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-body);
    border: 3px solid var(--border-color);
    z-index: 3;
    position: relative;
    transition: all 0.3s ease;
}

.step-dot.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.step-dot.completed {
    background: var(--bg-body);
    border-color: var(--accent-primary);
}

.chat-list-column {
    width: 340px;
    min-width: 340px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    z-index: 2;
}

.chat-list-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-item {
    padding: 16px;
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-active);
    border-left: 3px solid var(--accent-primary);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    min-width: 0;
    position: relative;
    height: 100%;
}

.chat-header-enhanced {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* --- Agenda View --- */
.calendar-view-container {
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.kpi-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: stretch;
}

.kpi-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(100px, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex: 1;
}

.calendar-day-header {
    background: var(--bg-body);
    padding: 12px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: white;
}

.calendar-day-cell {
    background: white;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.calendar-day-cell.inactive {
    background: #f8fafc;
}

.calendar-day-cell.today {
    background: #f0f9ff;
}

.day-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.event-chip {
    font-size: 10px;
    background: var(--bg-active);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 2px solid var(--accent-primary);
    margin-bottom: 2px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Toggle Switch Styles */
.switch {
    display: inline-block;
    position: relative;
    width: 44px;
    height: 24px;
    vertical-align: middle;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: '';
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #10b981;
}

input:focus+.slider {
    box-shadow: 0 0 1px #10b981;
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}