@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

:root {

    --bg-dark: #10121f;
    --bg-sidebar: #0b0d17;
    --bg-card: #1a1d30;
    --primary: #4f46e5;
    --primary-hover: #6366f1;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #2b304c;
    --success: #10b981;
    --danger: #ef4444;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

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

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1rem;
}

.sidebar-header i { font-size: 1.5rem; color: var(--primary); }
.sidebar-header h2 { font-size: 1.25rem; font-weight: 600; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 1rem;
    flex: 1;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-item i { width: 20px; text-align: center; }
.sidebar-item:hover, .sidebar-item.active { background-color: rgba(79, 70, 229, 0.1); color: var(--text-main); }
.sidebar-item.active { border-left: 3px solid var(--primary); border-radius: 0 8px 8px 0; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    display: flex;
    flex-direction: column;
}

/* Auth Container */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-container .card {
    max-width: 400px;
    background: rgba(26, 29, 48, 0.7);
    backdrop-filter: blur(10px);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-icon.primary { color: var(--primary); }
.stat-icon.success { color: var(--success); }
.stat-icon.danger { color: var(--danger); }

.stat-details h4 { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }
.stat-details p { font-size: 1.5rem; font-weight: 600; color: var(--text-main); }

/* Typography */
.page-title { margin-bottom: 2rem; }
.page-title h1 { font-size: 1.75rem; font-weight: 600; margin-bottom: 0.25rem; }
.page-title p { color: var(--text-muted); font-size: 0.95rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label { display: block; margin-bottom: 0.5rem; color: var(--text-muted); font-size: 0.875rem; }
input, select, textarea {
    width: 100%; padding: 0.75rem 1rem;
    background: var(--bg-dark); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-main); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

button {
    width: 100%; padding: 0.75rem 1.5rem;
    background: var(--primary); color: white;
    border: none; border-radius: 8px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
button:hover { background: var(--primary-hover); }
button.btn-secondary { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); color: var(--text-main); }
button.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}
.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
}

.btn-outline {
    display: inline-block;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-outline:hover {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Tables */
.table-container { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* Badges */
.badge {
    padding: 0.25rem 0.6rem; border-radius: 4px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
}
.badge.success { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge.active { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.inactive { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

/* Utilities */
.text-muted { color: var(--text-muted); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.toggle-form { text-align: center; margin-top: 1rem; font-size: 0.875rem; color: var(--text-muted); cursor: pointer; }
.toggle-form:hover { color: var(--primary); }

/* Messages UI */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: calc(100vh - 200px);
    min-height: 500px;
}
.messages-stats {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.messages-stats .stat-col {
    flex: 1;
    text-align: center;
    padding: 1.25rem 1rem;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}
.messages-stats .stat-col:last-child {
    border-right: none;
}
.messages-stats .stat-col h4 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    line-height: 1;
}
.messages-stats .stat-col p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.inbox-layout {
    display: flex;
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.inbox-sidebar {
    width: 320px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.2);
}
.inbox-search {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.inbox-search input {
    background: var(--bg-dark);
    padding-left: 2.5rem;
    position: relative;
}
.search-icon-wrap {
    position: relative;
}
.search-icon-wrap i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.contact-list {
    flex: 1;
    overflow-y: auto;
}
.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background 0.2s;
}
.contact-item:hover {
    background: rgba(255,255,255,0.02);
}
.contact-item.active {
    background: rgba(79,70,229,0.1);
    border-left: 3px solid var(--primary);
}
.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(16,185,129,0.15);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.contact-info {
    flex: 1;
    min-width: 0;
}
.contact-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    display: flex;
    justify-content: space-between;
}
.contact-msg {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inbox-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.inbox-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.inbox-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.inbox-header-name {
    font-size: 1rem;
    font-weight: 600;
}
.inbox-header-phone {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.inbox-messages-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: var(--bg-dark);
}
.inbox-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    background: var(--bg-dark);
}
.inbox-empty-state i {
    font-size: 2.5rem;
    opacity: 0.3;
}
.inbox-empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    opacity: 0.6;
}
.inbox-empty-state p {
    font-size: 0.85rem;
    text-align: center;
    max-width: 220px;
    opacity: 0.5;
}
.msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}
.msg-bubble-wrap.outbound {
    align-self: flex-end;
}
.msg-bubble-wrap.inbound {
    align-self: flex-start;
}
.msg-bubble {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.msg-bubble.outbound {
    background: #0f766e;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-bubble.inbound {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}
.msg-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.msg-bubble-wrap.outbound .msg-meta {
    justify-content: flex-end;
}
.msg-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    margin-bottom: 0.3rem;
}
.inbox-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    background: var(--bg-card);
}
.inbox-input-area input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 0.75rem 1.5rem;
}
.inbox-input-area button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}
.inbox-input-area button:hover {
    background: #059669;
}

/* Customer Dashboard */
.customer-search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    margin-bottom: 2rem;
    gap: 1rem;
}
.customer-search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 0.5rem;
    outline: none;
    font-size: 0.95rem;
}
.customer-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-sidebar);
    padding: 0.3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.customer-tab {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}
.customer-tab.active {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.customer-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.customer-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.customer-profile {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.customer-avatar-lg {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
}
.customer-details h3 {
    margin-bottom: 0.2rem;
    font-size: 1.1rem;
}
.customer-details p {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    gap: 1rem;
}
.customer-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.customer-stat-box {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 1rem;
}
.customer-stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.customer-stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
}
.customer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}
.customer-last-msg {
    color: var(--text-muted);
    font-size: 0.85rem;
}
