/* =========================================
   RESET + BASE
========================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
}

/* Links */
a {
    color: inherit;
    text-decoration: none;
}
a:hover {
    text-decoration: none;
}

/* Layout shell */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Main content area */
.app-main {
    flex: 1;
    padding: 32px 0 40px;
}

/* Centered page container */
.page-wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =========================================
   TOP NAV
========================================= */
.topnav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.topnav-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Left: logo */
.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-badge {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background:linear-gradient(135deg, #4d946c, #179747);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}

.logo-text-main {
    font-size: 15px;
    font-weight: 600;
}
.logo-text-sub {
    font-size: 11px;
    color: #6b7280;
}

/* Center: nav links */
.nav-center {
    display: flex;
    gap: 8px;
}

.nav-pill {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav-pill:hover {
    background: #e5e7eb;
    color: #111827;
}

.nav-pill--active {
    background: linear-gradient(135deg, #0d9f4c, #179747);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

/* Right: user/logout */
.nav-right {
    font-size: 12px;
    color: #6b7280;
}

/* =========================================
   PAGE HEADER
========================================= */
.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: #6b7280;
}

/* =========================================
   DASHBOARD STATS
========================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    padding: 18px 20px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.stat-card .stat-label {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-card .stat-note {
    font-size: 12px;
    color: #6b7280;
}

/* =========================================
   BUTTONS
========================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 16px;
    font-size: 13px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(79, 70, 229, 0.45);
}

.btn-light {
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}
.btn-light:hover {
    background: #f3f4f6;
}

.btn-danger {
    background: #ef4444;
    color: #ffffff;
}
.btn-danger:hover {
    background: #dc2626;
}

/* ============================
   AGENTS PAGE
   ============================ */

.agents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.agents-header .page-title {
    font-size: 22px;
    font-weight: 600;
    color: #111827;
}

.agents-header .page-subtitle {
    font-size: 13px;
    color: #6b7280;
}

.agents-header .page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Empty state */
.agents-empty {
    text-align: center;
    padding: 40px 24px;
}

.agents-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.agents-empty-text {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 20px;
}

/* Toolbar */
.agents-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    margin-top: 4px;
}

.agents-count {
    font-size: 13px;
    color: #6b7280;
}

/* Grid */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* Agent card */
.agent-card {
    display: flex;
    flex-direction: column;
    padding: 16px 18px;
    border-radius: 14px;
}

.agent-main {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.agent-avatar-wrap {
    flex-shrink: 0;
}

.agent-avatar {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}

.agent-avatar--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: #4b5563;
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.agent-name {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.agent-role {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 6px;
}

.agent-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
}

.agent-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.agent-meta-label {
    color: #9ca3af;
}

.agent-meta-value {
    color: #4b5563;
}

.agent-language-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: #eff6ff;
    color: #1d4ed8;
}

/* Status pill */
.status-pill {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
}

.status-pill--active {
    background: #ecfdf3;
    color: #15803d;
}

.status-pill--inactive {
    background: #fef2f2;
    color: #b91c1c;
}

/* Actions chips */
.agent-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.btn-chip {
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    background: #ffffff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-chip:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.btn-chip--whatsapp {
    border-color: #22c55e33;
    background: #ecfdf5;
    color: #15803d;
}

.btn-chip--whatsapp:hover {
    background: #bbf7d0;
    border-color: #22c55e;
}

.btn-chip--danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.btn-chip--danger:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
    .agents-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .agents-header .page-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .agents-grid {
        grid-template-columns: 1fr;
    }
}


/* =========================================
   FORMS
========================================= */
.form-card {
    max-width: 480px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.form-control,
select,
textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
}

.form-control:focus,
select:focus,
textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.4);
}

.form-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

/* Alert / empty state */
.empty-state {
    font-size: 13px;
    color: #6b7280;
}

/* =========================================
   FOOTER
========================================= */
.app-footer {
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #6b7280;
}

.footer-links {
    display: flex;
    gap: 16px;
}
.footer-links a {
    color: #6b7280;
}
.footer-links a:hover {
    color: #111827;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 720px) {
    .topnav-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .nav-center {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}
.onboarding-box {
    margin-top: 40px;
    background: #ffffff;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0px 4px 28px rgba(0,0,0,0.05);
}

.onboarding-sub {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 22px;
}

.onboarding-actions {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.onboarding-item {
    flex: 1;
    min-width: 240px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 18px;
}

.item-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.item-desc {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 14px;
}

.btn-secondary {
    display: inline-block;
    padding: 7px 14px;
    background: #eef2ff;
    border-radius: 6px;
    font-size: 13px;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    cursor: pointer;
    text-decoration: none;
}

.btn-secondary:hover {
    background: #e0e7ff;
}
/* ============================
   EDIT AGENT PAGE
   ============================ */

.agent-edit-card {
    max-width: 520px;
    margin: 0 auto;
    padding: 24px;
}

.agent-edit-avatar-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.agent-edit-avatar-preview img {
    width: 110px;
    height: 110px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid #e5e7eb;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}
/* ============================
   SETTINGS LAYOUT
   ============================ */

.settings-form {
    max-width: 1200px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 520px);
    gap: 24px;
    align-items: flex-start;
}

@media (min-width: 1100px) {
    .settings-grid {
        grid-template-columns: minmax(0, 520px) minmax(0, 520px);
    }
}

.settings-section {
    padding: 20px 22px;
}

.settings-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.settings-section-sub {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 16px;
}

.form-group-inline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (min-width: 768px) {
    .form-group-inline {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
}

.form-helper {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-row input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: transparent;
}

/* ============================
   BUSINESS HOURS TABLE
   ============================ */

.bh-table-wrapper {
    margin-top: 8px;
    overflow-x: auto;
}

.bh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.bh-table th,
.bh-table td {
    padding: 6px 4px;
}

.bh-table thead th {
    text-align: left;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.bh-table tbody tr:nth-child(odd) {
    background-color: #f9fafb;
}

.bh-day {
    font-weight: 500;
    color: #111827;
}

.bh-time-group input[type="time"] {
    width: 110px;
}

.bh-closed-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
}

.bh-input-disabled {
    background-color: #f3f4f6;
}

/* ============================
   MESSAGES GRID
   ============================ */

.message-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

@media (min-width: 768px) {
    .message-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.message-grid textarea {
    min-height: 70px;
    resize: vertical;
}

/* ============================
   AVATAR PREVIEW (edit agent)
   ============================ */

.form-avatar-preview {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
}

.form-avatar-preview img {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 15px rgba(15, 23, 42, 0.08);
}
/* ============================
   AUTH / LOGIN / REGISTER STYLES
============================ */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 16px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.06);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4d946c, #179747);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}

.auth-logo-title {
    font-size: 15px;
    font-weight: 600;
}

.auth-logo-subtitle {
    font-size: 11px;
    color: #6b7280;
}

.auth-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 18px;
}

.auth-form .form-row {
    margin-bottom: 14px;
}

.auth-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #374151;
}

.auth-form .input {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    padding: 9px 10px;
    font-size: 14px;
    outline: none;
}

.auth-form .input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 1px rgba(79,70,229,0.3);
}

.auth-footer {
    margin-top: 16px;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

.auth-footer a {
    color: #4f46e5;
    font-weight: 500;
}

.auth-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
}
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 800px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

.color-input-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-wrap input[type="color"] {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #ccc;
}
/* ============== LAYOUT FIXES ============== */

.page-wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 0;
}

.settings-form {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 24px;
    border-radius: 10px;
    margin-bottom: 28px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.settings-section-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-section-sub {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 18px;
}

/* ============== FORM ELEMENT FIXES ============== */

.form-group {
    margin-bottom: 16px;
}

.form-control {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 14px;
    background: #fff;
}

.form-control:focus {
    border-color: #6366f1; /* purple accent */
    outline: none;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

/* ============== BUTTONS ============== */

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-primary {
    background: #22c55e;
    border: none;
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-primary:hover {
    background: #4f46e5;
}

.btn-light {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #111;
    margin-right: 8px;
    padding: 8px 14px;
    border-radius: 6px;
}

/* ============== BUSINESS HOURS TABLE ============== */

.bh-table-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
}

.bh-table {
    width: 100%;
    border-collapse: collapse;
}

.bh-table th,
.bh-table td {
    padding: 6px 8px;
    font-size: 13px;
    border-bottom: 1px solid #f1f1f1;
}

.bh-table th {
    font-weight: 600;
    color: #374151;
}

.bh-time-input {
    width: 120px;
}

.bh-closed-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============== GRID HELPERS ============== */

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
/* ============================
   SETTINGS GRID 2×2
============================ */

.settings-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Card styling */
.settings-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px 24px 32px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* Titles inside cards */
.settings-card .settings-section-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-card .settings-section-sub {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 16px;
}

/* Form field spacing */
.settings-card .form-group {
    margin-bottom: 18px;
}

/* Button alignment */
.settings-card .form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Responsive behavior */
@media (max-width: 900px) {
    .settings-grid-2 {
        grid-template-columns: 1fr;
    }
}
/* ============== SETTINGS 2x2 CARDS ============== */

.settings-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
}

.settings-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.03);
}

.settings-card .settings-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-card .settings-section-sub {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 18px;
}

/* tighten form spacing inside cards */
.settings-card .form-group {
    margin-bottom: 14px;
}

.settings-card .form-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

/* alerts */
.alert {
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}
.alert-success {
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
    color: #166534;
}
.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}
