/* assets/css/app.css */
/* InboxCMD — Hybrid Theme (Dark Sidebar / Light Content) */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
    /* Sidebar */
    --sidebar-width:            220px;
    --sidebar-collapsed-width:  60px;
    --sidebar-bg:               #0D1130;
    --sidebar-text:             #7A8CAA;
    --sidebar-active-bg:        rgba(0,200,240,0.08);
    --sidebar-active-text:      #ffffff;
    --sidebar-hover-bg:         rgba(255,255,255,0.05);
    --sidebar-border:           rgba(255,255,255,0.06);

    /* Topnav */
    --topnav-height:            56px;
    --topnav-bg:                #ffffff;
    --topnav-border:            #e9ecef;

    /* Content */
    --page-bg:                  #f4f6f9;
    --card-bg:                  #ffffff;

    /* Brand */
    --brand-color:              #00C8F0;
    --brand-dark:               #008AAD;
    --brand-navy:               #07091A;

    /* Status colors */
    --success:                  #198754;
    --success-bg:               #d1e7dd;
    --danger:                   #dc3545;
    --danger-bg:                rgba(220,53,69,0.1);
    --danger-border:            rgba(220,53,69,0.25);
    --warning:                  #f0a030;
    --warning-bg:               #fff3cd;
    --info-bg:                  #cfe2ff;

    /* Fonts */
    --font-display:             'Space Grotesk', sans-serif;
    --font-body:                'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:                'JetBrains Mono', 'Courier New', monospace;

    /* Misc */
    --radius:                   8px;
    --radius-lg:                12px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin:      0;
    font-size:   0.9rem;
    background:  var(--page-bg);
    font-family: var(--font-body);
    color:       #343a40;
}

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

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
    width:          var(--sidebar-width);
    height:     100vh;
    background:     var(--sidebar-bg);
    display:        flex;
    flex-direction: column;
    position:       fixed;
    top:            0;
    left:           0;
    z-index:        100;
    transition:     width 0.2s ease;
    overflow:       hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    display:     flex;
    align-items: center;
    gap:         10px;
    padding:     0 16px;
    height:      var(--topnav-height);
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
}

.sidebar-brand-text {
    font-family:    var(--font-display);
    font-size:      1.05rem;
    font-weight:    700;
    color:          #ffffff;
    letter-spacing: -0.3px;
}

.sidebar-brand-text span { color: var(--brand-color); }

.sidebar-brand i {
    font-size:  1.2rem;
    color:      var(--brand-color);
    flex-shrink: 0;
}

.sidebar-client {
    padding:     0 16px 10px;
    margin-top: -4px;
}

.sidebar-client-label {
    font-family: var(--font-mono);
    font-size:   10px;
    color:       #4A5568;
}

.sidebar-client-domain {
    font-family: var(--font-mono);
    font-size:   11px;
    color:       var(--brand-color);
    white-space: nowrap;
    overflow:    hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    padding:    8px 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex:       1;
    min-height: 0;
}

.sidebar-section-label {
    font-size:      10px;
    font-weight:    600;
    color:          #4A5568;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding:        14px 16px 4px;
    white-space:    nowrap;
}

.sidebar-link {
    display:     flex;
    align-items: center;
    gap:         10px;
    padding:     9px 16px;
    color:       var(--sidebar-text);
    text-decoration: none;
    font-size:   0.85rem;
    white-space: nowrap;
    transition:  background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color:      #ffffff;
}

.sidebar-link.active {
    background:       var(--sidebar-active-bg);
    color:            var(--sidebar-active-text);
    border-left-color: var(--brand-color);
}

.sidebar-link i {
    font-size:   1rem;
    flex-shrink: 0;
    width:       20px;
    text-align:  center;
}

.sidebar-link .nav-badge {
    margin-left:   auto;
    background:    var(--brand-color);
    color:         var(--brand-navy);
    font-size:     10px;
    font-weight:   700;
    min-width:     18px;
    height:        18px;
    border-radius: 9px;
    display:       flex;
    align-items:   center;
    justify-content: center;
    padding:       0 5px;
}

.sidebar-link.danger-link { color: #e07070; }
.sidebar-link.danger-link:hover {
    color:      #ff8080;
    background: rgba(255,100,100,0.06);
}

.sidebar-bottom {
    border-top: 1px solid var(--sidebar-border);
    padding:    8px 0;
}

.sidebar-footer {
    border-top:  1px solid var(--sidebar-border);
    padding:     12px 16px;
    display:     flex;
    align-items: center;
    gap:         10px;
    white-space: nowrap;
}

.sidebar-footer .user-avatar {
    width:         30px;
    height:        30px;
    border-radius: 50%;
    background:    rgba(0,200,240,0.15);
    border:        1px solid rgba(0,200,240,0.3);
    color:         var(--brand-color);
    font-size:     11px;
    font-weight:   700;
    display:       flex;
    align-items:   center;
    justify-content: center;
    flex-shrink:   0;
    font-family:   var(--font-display);
}

.sidebar-footer .user-name {
    font-size:   12px;
    font-weight: 600;
    color:       #ffffff;
}

.sidebar-footer .user-role {
    font-size: 10px;
    color:     #4A5568;
}

#sidebarToggle i {
    display:    inline-block;
    transition: transform 0.2s ease;
}

#sidebarToggle.collapsed i {
    transform: rotate(180deg);
}

/* Hide labels when collapsed */
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sidebar-client,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-footer .user-name,
.sidebar.collapsed .sidebar-footer .user-role,
.sidebar.collapsed .nav-badge {
    display: none;
}

/* Pre-paint collapsed state (set synchronously in header.php before body
   renders) — avoids the width/margin transition playing on every full page
   load when the sidebar is already collapsed. */
html.sidebar-collapsed-init .sidebar {
    width: var(--sidebar-collapsed-width);
}

html.sidebar-collapsed-init .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

html.sidebar-collapsed-init .sidebar-label,
html.sidebar-collapsed-init .sidebar-section-label,
html.sidebar-collapsed-init .sidebar-client,
html.sidebar-collapsed-init .sidebar-brand-text,
html.sidebar-collapsed-init .sidebar-footer .user-name,
html.sidebar-collapsed-init .sidebar-footer .user-role,
html.sidebar-collapsed-init .nav-badge {
    display: none;
}

html.sidebar-collapsed-init #sidebarToggle i {
    transform: rotate(180deg);
}

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
    margin-left:    var(--sidebar-width);
    flex:           1;
    min-width:      0;
    display:        flex;
    flex-direction: column;
    min-height:     100vh;
    transition:     margin-left 0.2s ease;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* ── TOPNAV ───────────────────────────────────────────────── */
.topnav {
    height:        var(--topnav-height);
    background:    var(--topnav-bg);
    border-bottom: 1px solid var(--topnav-border);
    position:      sticky;
    top:           0;
    z-index:       99;
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    padding:       0 20px;
}

.topnav-left {
    display:     flex;
    align-items: center;
    gap:         12px;
}

.topnav-page-title {
    font-family: var(--font-display);
    font-size:   0.95rem;
    font-weight: 600;
    color:       #343a40;
}

.topnav-right {
    display:     flex;
    align-items: center;
    gap:         10px;
}

.topnav-status {
    display:     flex;
    align-items: center;
    gap:         6px;
    font-family: var(--font-mono);
    font-size:   11px;
    color:       #6c757d;
    padding:     4px 10px;
    background:  #f8f9fa;
    border:      1px solid #e9ecef;
    border-radius: var(--radius);
}

.status-dot {
    width:         7px;
    height:        7px;
    border-radius: 50%;
    background:    #198754;
    animation:     pulse 2s infinite;
    flex-shrink:   0;
}

.status-dot.offline {
    background: var(--danger);
    animation:  none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

.topnav-user {
    background:    none;
    border:        1px solid #e9ecef;
    border-radius: var(--radius);
    padding:       5px 10px;
    color:         #343a40;
    display:       flex;
    align-items:   center;
    gap:           8px;
    font-size:     0.85rem;
    cursor:        pointer;
    transition:    background 0.15s;
}

.topnav-user:hover {
    background:   #f8f9fa;
    border-color: #dee2e6;
}

.topnav-user .user-avatar {
    width:         28px;
    height:        28px;
    border-radius: 50%;
    background:    var(--brand-color);
    color:         var(--brand-navy);
    font-size:     11px;
    font-weight:   700;
    display:       flex;
    align-items:   center;
    justify-content: center;
    flex-shrink:   0;
    font-family:   var(--font-display);
}

/* ── PAGE BODY ────────────────────────────────────────────── */
.page-body {
    padding:   1.5rem;
    flex:      1;
    min-width: 0;
}

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

.page-title {
    font-family: var(--font-display);
    font-size:   1.2rem;
    font-weight: 700;
    color:       #212529;
    margin:      0;
}

.page-sub {
    font-size:  0.8rem;
    color:      #6c757d;
    margin-top: 2px;
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
    border-radius: var(--radius-lg);
    border:        1px solid #e9ecef;
    background:    var(--card-bg);
    box-shadow:    0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background:    #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding:       12px 18px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    display:       flex;
    align-items:   center;
    justify-content: space-between;
}

.card-title {
    font-family: var(--font-display);
    font-size:   0.9rem;
    font-weight: 600;
    color:       #212529;
    margin:      0;
}

.card-body { padding: 18px; }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stat-card {
    background:    var(--card-bg);
    border:        1px solid #e9ecef;
    border-radius: var(--radius-lg);
    padding:       18px;
    display:       flex;
    align-items:   center;
    gap:           14px;
    box-shadow:    0 1px 3px rgba(0,0,0,0.04);
}

.stat-icon {
    width:         46px;
    height:        46px;
    border-radius: 10px;
    display:       flex;
    align-items:   center;
    justify-content: center;
    font-size:     1.2rem;
    flex-shrink:   0;
}

.stat-value {
    font-family:  var(--font-display);
    font-size:    1.6rem;
    font-weight:  700;
    color:        #212529;
    line-height:  1;
}

.stat-label {
    font-size:  0.75rem;
    color:      #6c757d;
    margin-top: 3px;
}

/* ── TABLES ───────────────────────────────────────────────── */
.table {
    font-size: 0.85rem;
    color:     #343a40;
}

.table thead th {
    font-family:    var(--font-display);
    font-size:      0.75rem;
    font-weight:    600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color:          #6c757d;
    border-bottom:  2px solid #e9ecef;
    padding:        10px 14px;
    background:     #f8f9fa;
    white-space:    nowrap;
}

.table tbody td {
    padding:        10px 14px;
    border-bottom:  1px solid #f0f0f0;
    vertical-align: middle;
}

.table tbody tr:hover td { background: #f8f9fa; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge-open {
    background: #cfe2ff;
    color:      #084298;
    padding:    3px 9px;
    border-radius: 4px;
    font-size:  11px;
    font-weight: 600;
}

.badge-closed {
    background: #d1e7dd;
    color:      #0a3622;
    padding:    3px 9px;
    border-radius: 4px;
    font-size:  11px;
    font-weight: 600;
}

.badge-pending {
    background: #fff3cd;
    color:      #664d03;
    padding:    3px 9px;
    border-radius: 4px;
    font-size:  11px;
    font-weight: 600;
}

.badge-urgent {
    background: #f8d7da;
    color:      #842029;
    padding:    3px 9px;
    border-radius: 4px;
    font-size:  11px;
    font-weight: 600;
}

.badge-spam {
    background: #e2e3e5;
    color:      #41464b;
    padding:    3px 9px;
    border-radius: 4px;
    font-size:  11px;
    font-weight: 600;
}

/* ── FORMS ────────────────────────────────────────────────── */
.form-label {
    font-size:   0.82rem;
    font-weight: 500;
    color:       #495057;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-color);
    box-shadow:   0 0 0 3px rgba(0,200,240,0.12);
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn-primary {
    background:   var(--brand-color);
    border-color: var(--brand-color);
    color:        var(--brand-navy);
    font-family:  var(--font-display);
    font-weight:  600;
}

.btn-primary:hover {
    background:   var(--brand-dark);
    border-color: var(--brand-dark);
    color:        #ffffff;
}

.btn-outline-primary {
    border-color: var(--brand-color);
    color:        var(--brand-color);
    font-family:  var(--font-display);
    font-weight:  600;
}

.btn-outline-primary:hover {
    background:   var(--brand-color);
    border-color: var(--brand-color);
    color:        var(--brand-navy);
}

/* ── MODALS ───────────────────────────────────────────────── */
.modal-header {
    border-bottom: 1px solid #e9ecef;
    padding:       16px 20px;
}

.modal-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size:   1rem;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    padding:    12px 20px;
}

/* ── CONFIRM MODAL ────────────────────────────────────────── */
#confirmModal .modal-body {
    text-align: center;
    padding:    28px 24px;
}

#confirmModal .confirm-icon {
    font-size:     36px;
    margin-bottom: 12px;
    color:         var(--warning);
}

#confirmModal .confirm-message {
    font-size: 0.9rem;
    color:     #495057;
}

/* ── TOASTS ───────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom:   1.5rem;
    right:    1.5rem;
    z-index:  1100;
}

/* ── AUTH / LOGIN PAGES ───────────────────────────────────── */
.auth-wrapper {
    min-height:      100vh;
    display:         flex;
    align-items:     center;
    justify-content: center;
    background:      linear-gradient(135deg, #07091A 0%, #0D1130 100%);
}

.auth-card {
    width:         100%;
    max-width:     420px;
    border:        1px solid rgba(0,200,240,0.15);
    border-radius: var(--radius-lg);
    box-shadow:    0 8px 40px rgba(0,0,0,0.4);
    background:    #0D1130;
    color:         #F0F5FF;
}

.auth-card .card-body { padding: 40px 36px; }

.auth-logo {
    font-family:    var(--font-display);
    font-size:      22px;
    font-weight:    700;
    color:          #F0F5FF;
    margin-bottom:  6px;
    letter-spacing: -0.5px;
}

.auth-logo span { color: var(--brand-color); }

.auth-sub {
    font-size:     13px;
    color:         #7A8CAA;
    margin-bottom: 30px;
}

.auth-card .form-label { color: #B0BDCE; }

.auth-card .form-control {
    background:  #141840;
    border:      1px solid rgba(240,245,255,0.07);
    color:       #F0F5FF;
}

.auth-card .form-control:focus {
    background:   #141840;
    border-color: rgba(0,200,240,0.4);
    color:        #F0F5FF;
    box-shadow:   0 0 0 3px rgba(0,200,240,0.08);
}

.auth-card .form-control::placeholder { color: #4A5568; }

.auth-card .btn-primary {
    background:  var(--brand-color);
    border-color: var(--brand-color);
    color:       var(--brand-navy);
    width:       100%;
    padding:     11px;
    font-size:   15px;
    font-weight: 700;
}

.auth-card .alert-danger {
    background:   rgba(220,53,69,0.1);
    border-color: rgba(220,53,69,0.25);
    color:        #f08080;
    font-size:    13px;
}

/* ── SETUP WIZARD ─────────────────────────────────────────── */
.setup-wrapper {
    min-height:      100vh;
    display:         flex;
    align-items:     center;
    justify-content: center;
    background:      linear-gradient(135deg, #07091A 0%, #0D1130 100%);
    padding:         2rem 0;
}

.setup-card {
    width:         100%;
    max-width:     620px;
    border:        1px solid rgba(0,200,240,0.15);
    border-radius: var(--radius-lg);
    box-shadow:    0 8px 40px rgba(0,0,0,0.4);
}

.wizard-step         { display: none; }
.wizard-step.active  { display: block; }

.step-indicator {
    display:         flex;
    align-items:     center;
    justify-content: center;
    margin-bottom:   2rem;
}

.step-bubble {
    width:         36px;
    height:        36px;
    border-radius: 50%;
    display:       flex;
    align-items:   center;
    justify-content: center;
    font-weight:   600;
    font-size:     0.875rem;
    background:    #dee2e6;
    color:         #6c757d;
    transition:    all 0.2s;
    position:      relative;
    z-index:       1;
}

.step-bubble.active    { background: var(--brand-color); color: var(--brand-navy); }
.step-bubble.completed { background: #198754; color: #fff; }

.step-line {
    flex:       1;
    height:     3px;
    background: #dee2e6;
    max-width:  80px;
    transition: background 0.2s;
}

.step-line.completed { background: #198754; }

/* ── UTILITY ──────────────────────────────────────────────── */
.font-mono       { font-family: var(--font-mono); }
.font-display    { font-family: var(--font-display); }
.text-brand      { color: var(--brand-color) !important; }
.border-brand    { border-color: var(--brand-color) !important; }

.bg-success-subtle  { background-color: #d1e7dd !important; }
.bg-secondary-subtle { background-color: #e2e3e5 !important; }
.bg-warning-subtle  { background-color: #fff3cd !important; }
.bg-primary-subtle  { background-color: #cfe2ff !important; }
.bg-danger-subtle   { background-color: #f8d7da !important; }

/* ── SORTABLE TABLE COLUMNS ───────────────────────────────── */
.sortable-col {
    cursor:       pointer;
    user-select:  none;
    white-space:  nowrap;
}
.sortable-col .sort-icon {
    font-size: 11px;
    color:     #ced4da;
    margin-left: 4px;
}
.sortable-col.sort-asc .sort-icon,
.sortable-col.sort-desc .sort-icon {
    color: var(--brand-color);
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* ── HTML EDITOR (signature editor, email composers) ─────────── */
.html-editor-wrap {
    border:        1px solid #dee2e6;
    border-radius: 6px;
    overflow:      hidden;
}

.html-editor-toolbar {
    display:       flex;
    align-items:   center;
    gap:           2px;
    padding:       6px 8px;
    background:    #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-wrap:     wrap;
}

.editor-btn {
    background:    none;
    border:        1px solid transparent;
    border-radius: 4px;
    padding:       3px 7px;
    cursor:        pointer;
    font-size:     13px;
    color:         #495057;
    transition:    all 0.15s;
}

.editor-btn:hover {
    background:   #e9ecef;
    border-color: #dee2e6;
    color:        #212529;
}

.editor-btn.active {
    background:   #e9ecef;
    border-color: #ced4da;
    color:        #212529;
}

.editor-sep {
    width:      1px;
    height:     20px;
    background: #dee2e6;
    margin:     0 4px;
}

.editor-font-family,
.editor-font-size {
    width:      auto;
    height:     auto;
    padding:    3px 22px 3px 7px;
    font-size:  12px;
    border-color: transparent;
    background-color: transparent;
}

.editor-font-family { max-width: 150px; }
.editor-font-size   { max-width: 80px; }

.editor-font-family:hover,
.editor-font-size:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.html-editor-body {
    min-height:  120px;
    padding:     12px;
    font-size:   0.875rem;
    line-height: 1.6;
    color:       #212529;
    outline:     none;
    background:  #fff;
}

.html-editor-body:focus {
    box-shadow: inset 0 0 0 2px rgba(0,200,240,0.2);
}

.html-editor-body:empty:before {
    content:       attr(data-placeholder);
    color:         #adb5bd;
    pointer-events: none;
}

.paste-image-placeholder {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 0.8125rem;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 4px;
}

.html-source-view {
    width:       100%;
    min-height:  120px;
    padding:     12px;
    font-family: monospace;
    font-size:   12px;
    border:      none;
    outline:     none;
    resize:      vertical;
    background:  #1e1e2e;
    color:       #cdd6f4;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width:     var(--sidebar-collapsed-width);
        transform: translateX(-100%);
        transition: transform 0.25s;
    }
    .sidebar.open      { transform: translateX(0); }
    .main-content      { margin-left: 0; }
    .page-body         { padding: 1rem; }
    .auth-card .card-body { padding: 28px 20px; }
    #sidebarToggle     { display: none; }
}

