/* css/style.css */
:root {
    --primary-color: #007AFF;
    --secondary-color: #5856D6;
    --success-color: #34C759;
    --danger-color: #FF3B30;
    --warning-color: #FF9500;
    --background-color: #F2F2F7;
    --card-background: #FFFFFF;
    --text-color: #000000;
    --text-secondary: #8E8E93;
    --border-color: #C6C6C8;
    --separator-color: #E5E5EA;
    
    --radius-l: 20px;
    --radius-m: 12px;
    --radius-s: 8px;
    
    --shadow-s: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-m: 0 4px 16px rgba(0,0,0,0.08);
    
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    --nav-height: 84px; /* Includes safe area */
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 16px;
    line-height: 1.4;
    overflow-x: hidden;
    padding-bottom: var(--nav-height);
}

/* Typography */
h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 34px; letter-spacing: 0.37px; }
h2 { font-size: 28px; letter-spacing: 0.36px; }
h3 { font-size: 20px; letter-spacing: 0.38px; }
p { margin: 0 0 10px; color: var(--text-secondary); }

/* Layout Utilities */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--background-color);
    z-index: 10;
}

.view {
    display: none;
    height: 100%;
    flex-direction: column;
    padding: 20px 20px 100px; /* Bottom padding for nav */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.view.active { display: flex; }

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 20px;
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
}

/* Cards & Lists */
.card {
    background: var(--card-background);
    border-radius: var(--radius-m);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-s);
}

.list-group {
    background: var(--card-background);
    border-radius: var(--radius-m);
    overflow: hidden;
}

.list-item {
    padding: 16px;
    border-bottom: 1px solid var(--separator-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-background);
    transition: background 0.2s;
}

.list-item:last-child { border-bottom: none; }
.list-item:active { background: #F2F2F7; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border-radius: var(--radius-s);
    text-align: center;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 17px;
    transition: opacity 0.2s;
}

.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-secondary { background: rgba(118, 118, 128, 0.12); color: var(--primary-color); }
.btn-block { display: block; width: 100%; }
.btn-text { background: transparent; color: var(--primary-color); }

.icon-btn {
    background: #E5E5EA;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary-color);
}

.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--primary-color);
    color: white;
    font-size: 28px;
    border: none;
    box-shadow: var(--shadow-m);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Forms */
.input-group { margin-bottom: 16px; }
input[type="text"], input[type="password"], input[type="date"], input[type="tel"], textarea, select {
    width: 100%;
    padding: 12px 16px;
    font-size: 17px;
    border: 1px solid #C6C6C8;
    border-radius: var(--radius-s);
    background: var(--card-background);
    color: var(--text-color);
    -webkit-appearance: none;
}
textarea { resize: vertical; min-height: 80px; }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); /* Safari support */
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 10px;
    border-top: 0.5px solid rgba(0,0,0,0.1);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    text-decoration: none;
    color: #999;
    font-size: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nav-item ion-icon { font-size: 24px; margin-bottom: 4px; }
.nav-item.active { color: var(--primary-color); }

/* Login Screen */
#login-screen {
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    background: white;
}
#login-screen.active { display: flex; }
#login-screen h1 { margin-bottom: 10px; color: var(--primary-color); }

/* Dashboard Cards */
.summary-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.stat-card {
    min-width: 140px;
    background: white;
    padding: 16px;
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-s);
}
.stat-card h4 { font-size: 13px; color: var(--text-secondary); margin: 0 0 4px; font-weight: 500;}
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--text-color); }

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.chip {
    padding: 8px 16px;
    background: #E5E5EA;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-color);
    white-space: nowrap;
    cursor: pointer;
}

.chip.active {
    background: var(--primary-color);
    color: white;
}

/* Search Bar */
.search-bar {
    position: relative;
    margin-bottom: 16px;
    padding: 0 10px;
}
.search-bar input {
    width: 100%;
    padding: 10px 10px 10px 36px;
    border-radius: 10px;
    border: none;
    background: #E5E5EA;
    font-size: 17px;
}
.search-bar ion-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #8E8E93;
    font-size: 20px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: flex-end; /* Bottom sheet align */
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    width: 100%;
    border-top-left-radius: var(--radius-l);
    border-top-right-radius: var(--radius-l);
    padding: 20px;
    padding-bottom: 40px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal-content.full-screen {
    height: 100%;
    border-radius: 0;
    padding-bottom: 20px;
}

.modal-handle {
    width: 40px;
    height: 5px;
    background: #C6C6C8;
    border-radius: 3px;
    margin: 0 auto 20px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 20px;
    border-left: 2px solid var(--separator-color);
    margin-left: 10px;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
    padding-left: 15px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid white;
}

.timeline-date { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.timeline-content { background: white; padding: 10px; border-radius: var(--radius-s); box-shadow: var(--shadow-s); }

/* Loader */
.loader-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s;
}
.loader-container.hidden { opacity: 0; pointer-events: none; }

.spinner {
    width: 40px; height: 40px;
    border: 4px solid #E5E5EA;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Toast */
#toast-container {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
}

.toast {
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    margin-bottom: 10px;
    font-size: 14px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Lead Info Specifics */
.lead-profile h2 { margin-bottom: 5px; }
.lead-profile p { margin-bottom: 5px; }
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #E5E5EA;
    color: var(--text-color);
}
.status-New { background: #E3F2FD; color: #1976D2; }
.status-Follow-up { background: #FFF3E0; color: #F57C00; }
.status-Converted { background: #E8F5E9; color: #388E3C; }
.status-Interested { background: #F3E5F5; color: #7B1FA2; }

.action-bar {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}
.action-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}
.action-btn.call { background: #E3F2FD; color: #007AFF; }
.action-btn.whatsapp { background: #E8F5E9; color: #34C759; }
.action-btn.pay { background: #FFF3E0; color: #FF9500; }

.section-tabs {
    display: flex;
    border-bottom: 1px solid var(--separator-color);
    margin-bottom: 16px;
}
.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }

.lead-tab-content { display: none; }
.lead-tab-content.active { display: block; }

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state ion-icon {
    font-size: 48px;
    margin-bottom: 10px;
    color: #D1D1D6;
}
