/* ==========================================================================
   Elite Telecom eFax - Modern UI
   ========================================================================== */

:root {
    --sidebar-bg: #0f1117;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.15);
    --sidebar-width: 260px;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-hover: #4f46e5;
    --text-primary: #1e1e2e;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --page-bg: #f8fafc;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* --------------------------------------------------------------------------
   Global
   -------------------------------------------------------------------------- */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
    background: var(--sidebar-bg);
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.sidebar-brand:hover {
    text-decoration: none;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    flex-shrink: 0;
    object-fit: contain;
}

.sidebar-brand .brand-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.01em;
}

.sidebar-brand .brand-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
}

.sidebar-section {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 0.5rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.875rem;
    font-weight: 450;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sidebar .nav-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.7;
}

.sidebar .nav-link:hover {
    color: rgba(255, 255, 255, 0.9);
    background: var(--sidebar-hover);
}

.sidebar .nav-link:hover i {
    opacity: 1;
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    border-left-color: var(--accent);
}

.sidebar .nav-link.active i {
    opacity: 1;
    color: var(--accent-light);
}

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

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.sidebar-footer .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-footer .user-name {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .logout-btn {
    color: rgba(255, 255, 255, 0.4);
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.15s;
    text-decoration: none;
}

.sidebar-footer .logout-btn:hover {
    color: #f87171;
}

/* --------------------------------------------------------------------------
   Main Content
   -------------------------------------------------------------------------- */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-body {
    flex: 1;
    padding: 2rem;
}

/* --------------------------------------------------------------------------
   Page Headers
   -------------------------------------------------------------------------- */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.page-header .page-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

.card-body {
    padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    background: var(--card-bg);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stat-card .stat-icon.indigo  { background: #eef2ff; color: #6366f1; }
.stat-card .stat-icon.emerald { background: #ecfdf5; color: #10b981; }
.stat-card .stat-icon.amber   { background: #fffbeb; color: #f59e0b; }
.stat-card .stat-icon.rose    { background: #fff1f2; color: #f43f5e; }
.stat-card .stat-icon.sky     { background: #f0f9ff; color: #0ea5e9; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    white-space: nowrap;
    background: #fafbfc;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
    font-weight: 500;
    font-size: 0.7rem;
    padding: 0.3em 0.65em;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.badge-queued,
.badge.bg-warning  { background: #fef3c7 !important; color: #92400e !important; }

.badge-sending,
.badge.bg-info     { background: #e0f2fe !important; color: #075985 !important; }

.badge-sent,
.badge.bg-success  { background: #dcfce7 !important; color: #166534 !important; }

.badge-failed,
.badge.bg-danger   { background: #fee2e2 !important; color: #991b1b !important; }

.badge-inbox,
.badge.bg-primary  { background: #eef2ff !important; color: #3730a3 !important; }

.badge-archived,
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    padding: 0.45rem 1rem;
    transition: all 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.3rem 0.65rem;
}

/* --------------------------------------------------------------------------
   Auth Pages
   -------------------------------------------------------------------------- */

.auth-page {
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.auth-card .auth-logo {
    width: 48px;
    height: 48px;
    background: var(--accent);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin: 0 auto 1.25rem;
}

/* Image-based logo variant (SVG carries its own background/shape) */
img.auth-logo {
    background: none;
    object-fit: contain;
    display: block;
}

.auth-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.25rem;
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.auth-card .btn-primary {
    padding: 0.6rem;
    font-weight: 600;
}

.auth-card .form-control {
    padding: 0.6rem 0.75rem;
}

/* --------------------------------------------------------------------------
   Flash Messages
   -------------------------------------------------------------------------- */

.alert {
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: none;
    padding: 0.75rem 1rem;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info    { background: #e0f2fe; color: #075985; }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.page-link {
    color: var(--accent);
    border-color: var(--border-color);
    font-size: 0.85rem;
}

.page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Autocomplete Dropdown
   -------------------------------------------------------------------------- */

.autocomplete-dropdown {
    position: absolute;
    z-index: 1050;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.autocomplete-dropdown .autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

.autocomplete-dropdown .autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-dropdown .autocomplete-item:hover {
    background: #f8fafc;
}

.autocomplete-dropdown .autocomplete-item .contact-name {
    font-weight: 600;
}

.autocomplete-dropdown .autocomplete-item .contact-number {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

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

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

    .sidebar-toggle {
        display: block !important;
    }

    .content-body {
        padding: 1rem;
    }
}

/* --------------------------------------------------------------------------
   Component states: loading, skeleton, empty
   -------------------------------------------------------------------------- */

.text-accent { color: var(--accent) !important; }

/* Centered loading block for full-section spinners */
.loading-block {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

/* Button loading: hide label shift, keep size stable */
.btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

/* Skeleton shimmer placeholders */
.skeleton { padding: 0.25rem 0; }

.skeleton-line {
    height: 0.85rem;
    border-radius: var(--radius);
    margin: 0.5rem 0;
    background: linear-gradient(
        90deg,
        #eef1f5 25%,
        #f7f9fb 37%,
        #eef1f5 63%
    );
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

@keyframes skeleton-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: var(--accent);
    font-size: 1.5rem;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state-message {
    font-size: 0.875rem;
    margin-top: 0.35rem;
    max-width: 22rem;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-action {
    margin-top: 1.25rem;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    .skeleton-line { animation: none; }
    .stat-card { transition: none; }
}

/* Visible keyboard focus for all interactive elements */
.btn:focus-visible,
.nav-link:focus-visible,
.page-link:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
}

/* --------------------------------------------------------------------------
   Utility
   -------------------------------------------------------------------------- */

.text-muted {
    color: var(--text-secondary) !important;
}

.shadow-sm {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    margin-bottom: 1rem;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--accent);
}
