:root {
    --primary: #4f46e5;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --success: #10b981;
    --error: #ef4444;
    --accent: #6366f1;
    --warning: #f59e0b;
}

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

/* Custom Scrollbar for better UI */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* --- UI/UX: TOP NAVBAR --- */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    box-sizing: border-box;
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lang-switcher {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lang-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: 0.2s;
}

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

.lang-btn:hover:not(.active) {
    color: white;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

.pt-navbar {
    padding-top: 80px;
    /* Space for fixed navbar */
}

/* --- LOGINS & MODALS --- */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--card);
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 350px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10003;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: var(--card);
    width: 90%;
    max-width: 400px;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    box-sizing: border-box;
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 25px;
}

/* --- CARDS & LAYOUT --- */
.card {
    background: var(--card);
    padding: 25px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    position: relative;
    box-sizing: border-box;
}

.top-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.responsive-flex {
    display: flex;
    gap: 10px;
}

.flex-1 {
    flex: 1;
}

.align-center {
    align-items: center;
}

/* --- UI/UX: FORM GROUPING --- */
.settings-group {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.group-title {
    font-size: 1rem;
    color: var(--primary);
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-actions {
    background: rgba(79, 70, 229, 0.05);
    padding: 20px;
    border-radius: 12px;
    border: 1px dashed rgba(79, 70, 229, 0.3);
    margin-top: 10px;
}

/* --- TABLES & RESPONSIVE CONSTRAINTS --- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.client-table-wrapper {
    max-height: 400px;
    /* FIXED HEIGHT FOR LONG LISTS */
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.main-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 750px;
}

.main-table th {
    position: sticky;
    top: 0;
    background: #192233;
    /* Slightly darker header */
    z-index: 10;
    color: #94a3b8;
    font-size: 0.75rem;
    text-transform: uppercase;
    padding: 15px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.main-table td {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    background: rgba(255, 255, 255, 0.01);
}

.main-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Grids */
.grid-email {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
}

.grid-smtp,
.grid-actions,
.grid-tools,
.grid-booking {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.grid-booking {
    gap: 15px;
}

.meeting-link {
    grid-column: span 2;
    margin-top: 5px;
}

/* Margins */
.mt-10 {
    margin-top: 10px;
}

.mt-15 {
    margin-top: 15px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-10 {
    margin-bottom: 10px;
}

.vs-20 {
    margin-bottom: 20px;
}

.vsh-20 {
    margin-bottom: 6px;
}

/* Status & Quota */
.status-bar {
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid var(--primary);
    color: #818cf8;
    padding: 15px 20px;
    border-radius: 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.quota-container {
    display: none;
    padding: 20px;
}

.badge-plan {
    background: var(--accent);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    margin-left: 10px;
    text-transform: uppercase;
    font-weight: bold;
}

.quota-track {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.quota-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.4s ease;
    border-radius: 5px;
}

.quota-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
    position: relative;
}

label {
    display: block;
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-bottom: 6px;
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    box-sizing: border-box;
    transition: 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
    background: rgba(0, 0, 0, 0.4);
}

.file-input-custom {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 5px;
}

input[type="file"]::file-selector-button {
    background: var(--primary);
    border: none;
    border-radius: 6px;
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 15px;
    transition: 0.3s;
}

input[type="file"]::file-selector-button:hover {
    background: var(--accent);
}

/* Buttons */
.btn {
    cursor: pointer;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
}

.btn-auto {
    width: auto;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary.btn-auto {
    width: auto;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
    width: 100%;
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
    width: 100%;
}

.btn-warning {
    background: var(--warning);
    color: #000;
    width: 100%;
}

.btn-accent {
    background: var(--accent);
}

/* Table Actions */
.btn-table-action {
    padding: 6px 12px !important;
    font-size: 13px !important;
    width: auto !important;
    border-radius: 6px;
}

.btn-table-action i {
    pointer-events: none;
}

.upload-box {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    padding: 20px;
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.02);
    transition: 0.3s;
}

.upload-box:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.stat-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
}

.stat-cost {
    border-color: rgba(16, 185, 129, 0.3);
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
}

/* Switches & Modules */
.module-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(79, 70, 229, 0.2);
    margin-top: 5px;
    width: 100%;
    box-sizing: border-box;
}

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

.module-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
}

.module-desc {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 3px;
}

.switch-container {
    width: 100%;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
}

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

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

#isVoiceEnabled:checked+.slider {
    background-color: #818cf8 !important;
}

/* Colors */
.border-accent {
    border-color: rgba(79, 70, 229, 0.2);
}

.n8n-box {
    border-top: 1px solid rgba(16, 185, 129, 0.2);
    padding-top: 15px;
}

.input-success {
    border: 1px solid rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.domain-box {
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    padding-top: 15px;
}

.input-accent {
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.05);
}

.diagnostic-box {
    background: rgba(245, 158, 11, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.2);
    margin-bottom: 20px;
}

.debug-results {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.75rem;
    color: #cbd5e1;
    display: none;
}

.tools-box {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.05);
}

.danger-box {
    background: rgba(239, 68, 68, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.divider {
    opacity: 0.05;
    margin: 20px 0;
    border: 1px solid white;
}

/* Logo Input */
.logo-input-group {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.icon-preview {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* History */
.history-container {
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.crawl-status {
    display: none;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

/* Overlays */
#loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 90vw;
}

.toast {
    background: var(--card);
    color: var(--text);
    padding: 15px 25px;
    border-radius: 12px;
    border-left: 5px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.3s ease-out forwards;
    min-width: 250px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-20%);
    cursor: pointer;
    color: #94a3b8;
    padding: 5px;
}

.password-toggle:hover {
    color: white;
}

.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

/* --- MEDIA QUERIES (MOBILE OPTIMIZATION) --- */
@media (max-width: 900px) {
    .top-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .top-navbar {
        padding: 0 15px;
    }

    .admin-container {
        padding: 10px;
        gap: 15px;
    }

    .responsive-flex {
        flex-direction: column;
        align-items: stretch;
    }

    .responsive-flex select,
    .responsive-flex input,
    .responsive-flex button {
        width: 100%;
    }

    .grid-email,
    .grid-smtp,
    .grid-booking,
    .grid-actions,
    .grid-tools {
        grid-template-columns: 1fr;
    }

    .meeting-link {
        grid-column: span 1;
    }

    .card {
        padding: 15px;
    }

    .settings-group {
        padding: 15px;
    }

    .history-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    #companyListBody td div {
        flex-wrap: nowrap;
    }
}

@media (max-width: 600px) {
    #companyListBody td div {
        flex-direction: row;
    }
}