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

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #131b2e;
    --bg-tertiary: #1e294b;
    --card-bg: rgba(22, 30, 53, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);
    
    --accent: #d946ef;
    
    /* Status Colors */
    --status-novo: #64748b;
    --status-novo-bg: rgba(100, 116, 139, 0.15);
    --status-contatado: #0ea5e9;
    --status-contatado-bg: rgba(14, 165, 233, 0.15);
    --status-negociando: #f59e0b;
    --status-negociando-bg: rgba(245, 158, 11, 0.15);
    --status-fechado: #10b981;
    --status-fechado-bg: rgba(16, 185, 129, 0.15);
    --status-perdido: #ef4444;
    --status-perdido-bg: rgba(239, 68, 68, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(217, 70, 239, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--card-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px var(--primary-glow);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    list-style: none;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item a:hover, .nav-item.active a {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.nav-item.active a {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.02) 100%);
    border-left: 3px solid var(--primary);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.nav-item.logout {
    margin-top: auto;
}

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

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 2.5rem;
    overflow-y: auto;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

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

.page-title {
    font-size: 2rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Cards & Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

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

.metric-info h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dashboard Specifics */
.dashboard-sections {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
        padding: 1.25rem;
        gap: 1rem;
    }
    .nav-menu {
        flex-direction: row;
        justify-content: space-between;
        overflow-x: auto;
    }
    .nav-item.logout {
        margin-top: 0;
    }
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--accent));
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background-color: rgba(255,255,255,0.05);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: #ef4444;
    color: white;
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    background-color: var(--bg-secondary);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th, td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--card-border);
}

th {
    background-color: rgba(15, 23, 42, 0.4);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-novo { color: var(--status-novo); background-color: var(--status-novo-bg); }
.badge-contatado { color: var(--status-contatado); background-color: var(--status-contatado-bg); }
.badge-negociando { color: var(--status-negociando); background-color: var(--status-negociando-bg); }
.badge-fechado { color: var(--status-fechado); background-color: var(--status-fechado-bg); }
.badge-perdido { color: var(--status-perdido); background-color: var(--status-perdido-bg); }

/* Polling Screen */
.polling-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    gap: 1.5rem;
}

.spinner {
    width: 70px;
    height: 70px;
    border: 5px solid rgba(255, 255, 255, 0.05);
    border-top: 5px solid var(--primary);
    border-right: 5px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: relative;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

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

.progress-steps {
    width: 100%;
    max-width: 400px;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
    color: var(--text-secondary);
    transition: var(--transition);
}

.step-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.step-item.completed {
    color: #10b981;
}

.step-bullet {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.step-item.active .step-bullet {
    border-color: var(--primary);
    background-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px var(--primary-glow);
}

.step-item.completed .step-bullet {
    border-color: #10b981;
    background-color: #10b981;
    color: white;
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
}

.toast {
    background-color: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    transform: translateY(100px);
    opacity: 0;
    animation: slideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: var(--transition);
}

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.info { border-left-color: #0ea5e9; }

@keyframes slideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Details and forms split */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

/* Login Page Styling */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 1.75rem;
    margin-top: 1rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Inline Edit Actions */
.status-select {
    background-color: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

/* Interactive elements */
.action-links {
    display: flex;
    gap: 0.75rem;
}

.action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--card-border);
    text-decoration: none;
    transition: var(--transition);
}

.action-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.2);
}

.action-btn.whatsapp:hover {
    background-color: #25d366;
    color: white;
    border-color: #25d366;
}

/* Notes history log */
.notes-log {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.note-item {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.note-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.note-body {
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
}
