/**
 * Agency Client Portal - Modern SaaS Design System
 * Bootstrap 5 Enhanced Theme
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Color Palette */
    --primary: #4f46e5;
    --primary-rgb: 79, 70, 229;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;

    --secondary: #64748b;
    --secondary-rgb: 100, 116, 139;

    --success: #10b981;
    --success-rgb: 16, 185, 129;
    --success-light: #ecfdf5;

    --warning: #f59e0b;
    --warning-rgb: 245, 158, 11;
    --warning-light: #fffbeb;

    --danger: #ef4444;
    --danger-rgb: 239, 68, 68;
    --danger-light: #fef2f2;

    --info: #06b6d4;
    --info-rgb: 6, 182, 212;
    --info-light: #ecfeff;

    --dark: #0f172a;
    --dark-rgb: 15, 23, 42;
    --sidebar-bg: #ffffff;
    --sidebar-text: #475569;
    --sidebar-text-muted: #94a3b8;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --sidebar-hover-bg: #f8fafc;

    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-subtle: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 14px 28px -4px rgba(15, 23, 42, 0.08), 0 6px 12px -2px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

body {
    font-family: var(--font-sans);
    background-color: var(--body-bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(244, 63, 94, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    letter-spacing: -0.01em;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--dark);
    letter-spacing: -0.02em;
}

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

/* Sidebar Styling - Premium Lighting Theme */
.app-sidebar {
    width: 270px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 16px rgba(15, 23, 42, 0.03);
}

.sidebar-header {
    height: 72px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #0f172a;
    font-weight: 700;
    font-size: 1.15rem;
    font-family: var(--font-heading);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.sidebar-menu {
    padding: 1.25rem 0.875rem;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 0.75rem 0.75rem 0.35rem;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.nav-link-item i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    transition: transform 0.2s ease;
}

.nav-link-item:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.nav-link-item:hover i {
    transform: scale(1.1);
    color: var(--primary);
}

.nav-link-item.active {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
    font-weight: 600;
}

.nav-link-item.active i {
    color: #ffffff;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

/* Main Content Area */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--body-bg);
}

/* Navbar */
.app-navbar {
    height: 72px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-subtle);
}

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

/* Cards */
.card-modern {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.04), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
    border-color: #cbd5e1;
}

/* Premium Stat Cards */
.card-stat {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    position: relative;
    overflow: hidden;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.04);
}

.card-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, #38bdf8 100%);
    opacity: 0.85;
    transition: height 0.25s ease;
}

.card-stat:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px -4px rgba(15, 23, 42, 0.1), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
    border-color: #cbd5e1;
}

.card-stat:hover::before {
    height: 4px;
}

.card-stat .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

.stat-trend.up {
    background-color: #ecfdf5;
    color: #059669;
}

.stat-trend.neutral {
    background-color: #f1f5f9;
    color: #64748b;
}

.stat-trend.down {
    background-color: #fef2f2;
    color: #dc2626;
}

/* Dashboard Hero Banner - Premium Lighting Theme */
.dashboard-hero {
    background: linear-gradient(135deg, #ffffff 0%, #f6f8fe 45%, #eef2ff 100%);
    border-radius: var(--radius-xl);
    padding: 2.25rem 2.5rem;
    color: #0f172a;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px -5px rgba(79, 70, 229, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.dashboard-hero::after {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, rgba(6, 182, 212, 0.12) 50%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero-metric-chip {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 14px;
    padding: 0.75rem 1.15rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero-metric-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.08);
}

/* Mobile App Version Badge (Visible strictly on mobile screens) */
.mobile-app-version-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #4f46e5;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.08);
    white-space: nowrap;
}

.mobile-app-version-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.76rem;
    color: #475569;
}

@media (min-width: 992px) {
    .mobile-app-version-pill,
    .mobile-app-version-banner,
    .mobile-only-version {
        display: none !important;
    }
}

/* Gradient Progress Bars */
.progress-gradient {
    height: 7px;
    border-radius: 10px;
    background-color: #f1f5f9;
    overflow: hidden;
}

.progress-gradient .progress-bar {
    background: linear-gradient(90deg, #4f46e5 0%, #06b6d4 100%);
    border-radius: 10px;
}

/* Soft Badges */
.badge-soft-primary {
    background-color: #eef2ff;
    color: #4f46e5;
    border: 1px solid rgba(79, 70, 229, 0.15);
}

.badge-soft-success {
    background-color: #ecfdf5;
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.badge-soft-warning {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.badge-soft-danger {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.badge-soft-info {
    background-color: #ecfeff;
    color: #0891b2;
    border: 1px solid rgba(6, 182, 212, 0.15);
}

.badge-soft-secondary {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid rgba(100, 116, 139, 0.15);
}

.badge-soft-dark {
    background-color: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

/* Activity Timeline */
.timeline-stream {
    position: relative;
    padding-left: 2rem;
}

.timeline-stream::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 11px;
    width: 2px;
    background: #e2e8f0;
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-icon {
    position: absolute;
    left: -2rem;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--primary);
    z-index: 2;
}

/* Drag and Drop Zone */
.dropzone-container {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 2.25rem 1.5rem;
    text-align: center;
    background-color: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropzone-container:hover, .dropzone-container.dragover {
    border-color: var(--primary);
    background-color: #f5f3ff;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 100px;
    border: 1px solid var(--border-color);
    background: #fff;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
}

/* Impersonation Banner */
.impersonation-bar {
    background: linear-gradient(90deg, #f59e0b 0%, #ea580c 100%);
    color: #ffffff;
    padding: 0.5rem 1.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Ticket Chat System */
.chat-window {
    display: flex;
    flex-direction: column;
    height: 540px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.chat-messages {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.chat-bubble {
    max-width: 78%;
    padding: 1rem 1.25rem;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
    word-break: break-word;
}

.chat-bubble.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}

.chat-bubble.mine .text-muted,
.chat-bubble.mine .chat-meta {
    color: rgba(255, 255, 255, 0.75) !important;
}

.chat-bubble.theirs {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: #1e293b;
    border-bottom-left-radius: 3px;
}

.chat-bubble.theirs .chat-meta {
    color: #64748b;
}

.chat-input-area {
    padding: 1rem 1.25rem;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
    font-weight: 500;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* Mobile Sidebar Drawer */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -270px;
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar.show {
        left: 0;
    }
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1030;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Content Spacing */
    .content-body {
        padding: 1.25rem 1rem 5rem 1rem !important; /* Bottom clearance for mobile bottom bar */
    }

    .app-navbar {
        padding: 0 1rem;
        height: 64px;
    }

    .dashboard-hero {
        padding: 1.5rem 1.25rem;
        border-radius: var(--radius-lg);
    }
}

/* Mobile Sticky Bottom Navigation Bar */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 767.98px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(255, 255, 255, 0.94);
        backdrop-filter: blur(16px);
        border-top: 1px solid #e2e8f0;
        z-index: 1025;
        align-items: center;
        justify-content: space-around;
        padding: 0 0.5rem;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    }

    .mobile-nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #64748b;
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 600;
        gap: 3px;
        flex: 1;
        height: 100%;
        transition: color 0.15s ease;
    }

    .mobile-nav-link i {
        font-size: 1.15rem;
    }

    .mobile-nav-link.active, .mobile-nav-link:hover {
        color: var(--primary);
    }
}

/* Glassmorphism & Modern Tables */
.table-responsive-custom {
    border-radius: var(--radius-lg);
    border: 1px solid #e2e8f0;
    overflow-x: auto;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.table-responsive-custom .table {
    margin-bottom: 0;
}

.table-responsive-custom .table th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.table-responsive-custom .table td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
}

.table-responsive-custom .table tr:last-child td {
    border-bottom: none;
}

.table-responsive-custom .table tbody tr {
    transition: background-color 0.15s ease;
}

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

/* Fluid Responsiveness for All Screen Sizes */
@media (max-width: 575.98px) {
    .card-stat {
        padding: 1.15rem 1rem !important;
        border-radius: var(--radius-md) !important;
    }

    .card-stat .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.15rem !important;
        border-radius: 10px !important;
    }

    .dashboard-hero {
        padding: 1.35rem 1rem !important;
    }

    .dashboard-hero h2 {
        font-size: 1.35rem !important;
    }

    .timeline-stream {
        padding-left: 1.5rem !important;
    }

    .timeline-icon {
        left: -1.5rem !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 0.55rem !important;
    }

    .content-body {
        padding: 1rem 0.75rem 5rem 0.75rem !important;
    }
}

/* Tablet Optimizations */
@media (min-width: 768px) and (max-width: 991.98px) {
    .content-body {
        padding: 1.5rem 1.25rem !important;
    }
}

/* Touch Device Optimization */
@media (hover: none) {
    .card-stat:hover, .card-hover:hover {
        transform: none !important;
    }
}
