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

:root {
    --bg-main: #08090a; /* Deep tech black */
    --bg-card: rgba(20, 22, 26, 0.7); /* Slate gray transparent panel */
    --border-color: rgba(255, 255, 255, 0.08); /* Crisp glass border */
    
    --color-primary: #f06a28; /* Vibrant rust orange */
    --color-secondary: #ffffff; /* Crisp white */
    --color-success: #38b000; /* Vibrant green */
    --color-warning: #ffaa00; /* Amber yellow */
    --color-danger: #d90429; /* Vibrant red */
    --color-text-main: #ffffff;
    --color-text-muted: #94a3b8; /* Cool gray slate */
    --font-outfit: 'Outfit', sans-serif;
    --font-inter: 'Inter', sans-serif;
    
    --shadow-neon: 0 0 20px rgba(240, 106, 40, 0.12);
    --shadow-cyan: 0 0 20px rgba(255, 255, 255, 0.08);
    --shadow-green: 0 0 20px rgba(56, 176, 0, 0.10);
}

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

body {
    background-color: var(--bg-main);
    color: var(--color-text-main);
    font-family: var(--font-inter);
    overflow-x: hidden;
    height: 100vh;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(240, 106, 40, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.03) 0%, transparent 40%);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-neon);
}

.title-outfit {
    font-family: var(--font-outfit);
    font-weight: 700;
}

/* Auth Section */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

.auth-logo p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--color-text-main);
    font-family: var(--font-inter);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(240, 106, 40, 0.2);
    background: rgba(255, 255, 255, 0.06);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary) 0%, #ff8c42 100%);
    border: none;
    border-radius: 8px;
    padding: 14px;
    color: #ffffff;
    font-family: var(--font-outfit);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(240, 106, 40, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 106, 40, 0.4);
    background: linear-gradient(135deg, #ff8c42 0%, var(--color-primary) 100%);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 18px;
    color: var(--color-text-main);
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-text-muted);
}

.btn-danger {
    background: rgba(255, 0, 127, 0.15);
    border: 1px solid rgba(255, 0, 127, 0.3);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--color-danger);
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}
.btn-danger:hover {
    background: var(--color-danger);
    color: white;
}

/* Layout Core */
#main-app {
    display: flex;
    height: 100vh;
    width: 100vw;
    display: none; /* Shown after auth */
}

/* Sidebar */
.sidebar {
    width: 260px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100%;
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: 40px;
}

#company-logo-container {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 8px 16px !important;
    box-sizing: border-box !important;
}

#company-logo-img {
    max-width: 100% !important;
    max-height: 36px !important;
    height: auto !important;
    object-fit: contain !important;
    border-radius: 6px;
    padding-right: 12px !important; /* Safety padding to prevent browser scaling clipping on the right edge */
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-family: var(--font-outfit);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-item:hover, .nav-item.active {
    color: var(--color-text-main);
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    border-left: 3px solid var(--color-primary);
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.user-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.logout-btn {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-danger);
    padding: 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(217, 4, 41, 0.1);
    border-color: rgba(217, 4, 41, 0.2);
}

/* App Body and Workspace */
.app-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

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

.content-header h2 {
    font-family: var(--font-outfit);
    font-size: 1.4rem;
}

.app-workspace {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    gap: 30px;
}

.workspace-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.panel-view {
    display: none;
    height: 100%;
}

.panel-view.active {
    display: flex;
    flex-direction: column;
}

/* Grid Dashboard Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    padding: 24px;
}

.metric-card h3 {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.metric-card .value {
    font-family: var(--font-outfit);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.metric-card .trend {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.trend.up { color: var(--color-success); }
.trend.down { color: var(--color-danger); }

/* Table Elements */
.table-container {
    flex-grow: 1;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

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

.custom-table th {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px 20px;
    color: var(--color-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-outfit);
}

.custom-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

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

.custom-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.badge-ia { background: rgba(240, 106, 40, 0.12); color: #ff9f68; border: 1px solid rgba(240, 106, 40, 0.3); }
.badge-waiting { background: rgba(217, 4, 41, 0.12); color: #ff5c77; border: 1px solid rgba(217, 4, 41, 0.3); box-shadow: var(--shadow-neon); }
.badge-human { background: rgba(255, 255, 255, 0.1); color: var(--color-secondary); border: 1px solid rgba(255, 255, 255, 0.2); }
.badge-success { background: rgba(56, 176, 0, 0.12); color: #55eb2a; border: 1px solid rgba(56, 176, 0, 0.3); }

/* Live Chat Layout */
.live-chat-panel {
    display: flex;
    flex-grow: 1;
    height: 100%;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.15);
}

.chat-sidebar-search {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.leads-list {
    flex-grow: 1;
    overflow-y: auto;
    list-style: none;
}

.lead-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lead-item:hover, .lead-item.active {
    background: rgba(255, 255, 255, 0.03);
}

.lead-item.active {
    border-left: 4px solid var(--color-primary);
}

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

.lead-item-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.lead-item-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.lead-item .last-msg {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: rgba(20, 20, 25, 0.2);
}

.chat-area-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.1);
}

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

.chat-msg-row {
    display: flex;
    width: 100%;
}

.chat-msg-row.customer { justify-content: flex-start; }
.chat-msg-row.operator, .chat-msg-row.ia { justify-content: flex-end; }

.chat-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg-row.customer .chat-bubble {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-main);
    border-bottom-left-radius: 2px;
}

.chat-msg-row.operator .chat-bubble {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-msg-row.ia .chat-bubble {
    background: rgba(240, 106, 40, 0.12);
    color: #ffe5d8;
    border: 1px solid rgba(240, 106, 40, 0.3);
    border-bottom-right-radius: 2px;
}

.chat-msg-meta {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 4px;
    text-align: right;
    display: block;
}

.chat-area-input {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.1);
}

.chat-area-input input {
    flex-grow: 1;
}

.chat-area-input button {
    font-family: var(--font-outfit);
    padding: 0 20px;
}

/* Chat Handoff Actions Banner */
.handoff-banner {
    background: rgba(255, 0, 127, 0.1);
    border-bottom: 1px solid rgba(255, 0, 127, 0.2);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

/* Interactive WhatsApp Simulator Layout */
.simulator-wrapper {
    width: 360px;
    height: 640px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-radius: 40px;
    border: 12px solid #22252a;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), var(--shadow-cyan);
    overflow: hidden;
    background: #075e54; /* WhatsApp classic green theme base */
    position: relative;
}

.sim-notch {
    height: 25px;
    background: #22252a;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
}

.sim-notch-bar {
    width: 120px;
    height: 15px;
    background: #000;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

.sim-header {
    background: #075e54;
    color: white;
    padding: 30px 15px 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sim-header-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.sim-header-info p {
    font-size: 0.75rem;
    opacity: 0.8;
}

.sim-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); /* standard whatsapp bg */
    background-size: cover;
}

.sim-msg-row {
    display: flex;
    width: 100%;
}
.sim-msg-row.out { justify-content: flex-end; }
.sim-msg-row.in { justify-content: flex-start; }

.sim-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #303030;
    line-height: 1.4;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    position: relative;
}

.sim-msg-row.out .sim-bubble {
    background: #dcf8c6;
    border-top-right-radius: 0;
}

.sim-msg-row.in .sim-bubble {
    background: white;
    border-top-left-radius: 0;
}

.sim-msg-time {
    font-size: 0.65rem;
    color: #8c8c8c;
    text-align: right;
    display: block;
    margin-top: 3px;
}

/* Chat Simulator Context Info Cards (Fipe, Pix, Login) */
.sim-interactive-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    margin-top: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sim-interactive-card h5 {
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
}

.sim-interactive-card p {
    font-size: 0.75rem;
    color: #64748b;
}

.sim-interactive-card button {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
}

.sim-interactive-card .input-sim-field {
    padding: 6px;
    font-size: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
}

.sim-footer {
    background: #f0f0f0;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.sim-footer input {
    flex-grow: 1;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 0.85rem;
    color: #333;
}
.sim-footer input:focus {
    outline: none;
    border-color: #075e54;
}

.sim-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #075e54;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 30px;
}

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

.modal-header h3 {
    font-family: var(--font-outfit);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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