/* ===== Variables ===== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --sidebar-width: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #334155;
    --border-color: #e2e8f0;
}

[data-bs-theme="dark"] {
    --body-bg: #0f172a;
    --card-bg: #1e293b;
    --text-color: #e2e8f0;
    --border-color: #334155;
}

/* ===== Base ===== */
body {
    background: var(--body-bg);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h5 {
    color: #ffffff;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sidebar-nav li a:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}

.sidebar-nav li a.active {
    color: #ffffff;
    background: var(--primary);
    font-weight: 600;
}

.sidebar-nav li a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-section {
    padding: 1rem 1.25rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148,163,184,0.6);
    font-weight: 700;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-wrapper {
    padding: 1.5rem 2rem;
}

.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--sidebar-text);
    margin-top: 0.25rem;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* ===== Contact Cards ===== */
.contact-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.contact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

/* ===== Status Buttons ===== */
.status-btn {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
}

.status-draft { background: #64748b; color: white; border-color: #64748b; }
.status-sent { background: #3b82f6; color: white; border-color: #3b82f6; }
.status-accepted { background: #10b981; color: white; border-color: #10b981; }
.status-rejected { background: #ef4444; color: white; border-color: #ef4444; }

/* ===== Toggle Buttons ===== */
.toggle-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

/* ===== Tables ===== */
.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--sidebar-text);
    border-bottom-width: 2px;
}

.table td {
    vertical-align: middle;
}

/* ===== Login ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ===== Toast alerts ===== */
.toast-alert {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

.sidebar-overlay.show {
    display: block;
}

/* ===== Forms ===== */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37,99,235,0.15);
}

/* ===== Quill Editor ===== */
.ql-toolbar.ql-snow {
    border-radius: 8px 8px 0 0;
    border-color: var(--border-color);
}

.ql-container.ql-snow {
    border-radius: 0 0 8px 8px;
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .ql-toolbar.ql-snow,
[data-bs-theme="dark"] .ql-container.ql-snow {
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .ql-snow .ql-stroke {
    stroke: var(--sidebar-text);
}

[data-bs-theme="dark"] .ql-snow .ql-fill {
    fill: var(--sidebar-text);
}

[data-bs-theme="dark"] .ql-snow .ql-picker-label {
    color: var(--sidebar-text);
}

[data-bs-theme="dark"] .ql-editor {
    color: var(--text-color);
}

/* ===== Responsive ===== */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }
}
