/* ===========================================================
   Inquiry CRM — Professional SaaS Design System
   Font: Jost | Theme: Bright/White | Density: Compact
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Premium Light */
    --primary: #4f46e5;         /* Indigo 600 */
    --primary-hover: #4338ca;
    --primary-light: #f5f3ff;
    
    --accent: #8b5cf6;          /* Violet 500 */
    --accent-light: #f5f3ff;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Neutrals */
    --bg-main: #f8fafc;         /* Slate 50 */
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.9);
    --bg-tertiary: #f1f5f9;     /* Slate 100 */
    
    --text-primary: #1e293b;    /* Slate 800 */
    --text-secondary: #475569;  /* Slate 600 */
    --text-muted: #94a3b8;      /* Slate 400 */
    
    --border-color: #e2e8f0;    /* Slate 200 */
    --input-border: #cbd5e1;    /* Slate 300 */
    
    /* Layout Density - Compact */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Shadows - Subtle */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04);
    
    --transition: all 0.2s ease-out;
}

/* Base Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; } /* Professional compact size */

body {
    font-family: 'Jost', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { 
    text-decoration: none; 
    color: var(--primary); 
    transition: var(--transition); 
}
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600; /* Professional reduced weight */
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

ul { list-style: none; }

button, input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

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

.header.expanded {
    left: 0;
}

.page-content {
    padding: 24px;
    max-width: 1480px;
    margin: 0 auto;
    transition: var(--transition);
}

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

.sidebar-brand {
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.sidebar-brand .brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-section { margin-bottom: 20px; }

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-icon { 
    width: 18px; 
    height: 18px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* Header */
.header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 90;
    transition: var(--transition);
}

.page-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.breadcrumb span, .breadcrumb a { color: var(--text-muted); }
.breadcrumb .active { color: var(--text-secondary); font-weight: 500; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    margin-bottom: 16px;
}

.card:hover { border-color: var(--input-border); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.card-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: default;
}

.stat-card:hover { 
    border-color: var(--primary); 
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.clickable {
    cursor: pointer;
    text-decoration: none;
    display: flex;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 2px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* Tables */
.table-container { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border-color); }

table { width: 100%; border-collapse: collapse; }

thead th {
    padding: 14px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    background: #fafafa;
    border-bottom: 1px solid var(--border-color);
}

tbody td {
    padding: 14px 20px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover { background: #fdfdfd; }

/* Badges */
.badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Table Layout Utilities */
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.v-middle { vertical-align: middle; }
.w-min { width: 1%; white-space: nowrap; }
.w-100 { width: 100%; }
.text-nowrap { white-space: nowrap; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

/* Hover Reveal Effect */
.btn-hover-reveal .btn-text {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    display: inline-block;
    vertical-align: middle;
}

.btn-hover-reveal:hover .btn-text {
    max-width: 200px;
    opacity: 1;
    margin-left: 8px;
    color: #fff;
}

.btn i, .btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff !important; }

.btn-secondary { background: #fff; color: var(--text-secondary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-main); border-color: var(--input-border); }

.btn-danger { background: #fff; color: var(--danger); border-color: #fee2e2; }
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto; /* Enable scrolling for long modals */
    align-items: flex-start; /* Start from top to ensure full visibility */
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    margin: auto 0; /* Vertical centering while allowing scroll */
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }

.modal-header {
    padding: 16px 24px;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* Page Header - Professional Alignment */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header .header-content {
    flex: 1;
}

.page-header h1 {
    font-size: 24px;
    margin: 0;
    line-height: 1.2;
}

.page-header .btn {
    margin-left: 0; /* Button on the left/start is achieved via order or placement */
}

/* Lucide and SVG sizing */
.lucide {
    width: 1em;
    height: 1em;
    stroke-width: 2px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { 
        transform: translateX(-100%); 
        box-shadow: 20px 0 50px rgba(0,0,0,0.1);
    }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .header { left: 0; padding: 0 16px; }
    
    /* Overlay when sidebar is active */
    .sidebar.active::after {
        content: '';
        position: fixed;
        inset: 0;
        left: var(--sidebar-width);
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        z-index: -1;
    }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .form-row { grid-template-columns: 1fr; gap: 8px; }
    .page-content { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header .header-actions { width: 100%; display: flex; }
    .page-header .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .card { padding: 12px; }
    .header-right .btn-text { display: none; }
    .header-right .btn { padding: 8px; }
}

/* Utilities */
.text-accent { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }

/* Ticket Details Sidebar Metadata */
.ticket-meta {
    display: flex;
    flex-direction: column;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Better for multi-line values */
    padding: 10px 0;
    border-bottom: 1px dotted var(--border-color);
}

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

.meta-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.meta-value .badge {
    margin-top: -2px;
}

/* Ticket Communication / Comments */
.comment-thread {
    display: flex;
    flex-direction: column;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.comment-designation {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comment-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto; /* Push time to the right */
}

.comment-text {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-secondary);
    padding-left: 0;
}

/* Password Toggle Wrapper */
.password-field-wrapper {
    position: relative;
    width: 100%;
}

.password-field-wrapper .form-control {
    padding-right: 42px; /* Space for the eye icon */
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 10;
    transition: var(--transition);
}

.password-toggle-btn:hover {
    color: var(--primary);
}

.password-toggle-btn svg {
    width: 18px;
    height: 18px;
}

/* Modern Table Enhancements */
.modern-table {
    border: none !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.modern-table thead th {
    background: transparent !important;
    border-bottom: 2px solid #f1f5f9 !important;
    color: #94a3b8 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

.modern-table tbody tr {
    transition: all 0.2s ease !important;
}

.modern-table tbody tr:hover {
    background: #f8fafc !important;
    transform: scale(1.002);
    box-shadow: 0 4px 20px -10px rgba(0, 0, 0, 0.1);
}

/* Avatar Utilities */
.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}

/* Dashboard Main Layout - Match Section Heights */
.dashboard-main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: stretch; /* Match left and right card heights */
}

.dashboard-main-grid > .card,
.dashboard-main-grid > div > .card {
    height: 100%;
    margin-bottom: 0;
}

@media (max-width: 1200px) {
    .dashboard-main-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        align-items: start; /* Don't stretch when stacked vertically */
    }
}

/* Dashboard Sidebar Card Improvements */
.dashboard-sidebar-card {
    padding: 16px;
}

@media (max-width: 768px) {
    .dashboard-sidebar-card {
        padding: 16px;
    }
}

/* Ensure tables don't break layout */
.table-container {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Table Optimization */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .modern-table td, 
    .modern-table th {
        padding: 12px 8px !important;
        font-size: 12px !important;
    }
    
    .btn-xs {
        padding: 6px 10px !important;
        font-size: 10px !important;
        white-space: nowrap;
    }
}

