/**
 * Main Stylesheet
 * Customer Care Ticket System
 * Color Scheme: #2a2a72 (Primary), White (Background)
 */

/* ============================================
   CSS VARIABLES & ROOT
   ============================================ */
:root {
    --primary-color: #2a2a72;
    --primary-dark: #1f1f54;
    --primary-light: #3d3d9a;
    --secondary-color: #6c63ff;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-base: 14px;
    --font-size-sm: 12px;
    --font-size-lg: 16px;
    --font-size-xl: 20px;

    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;

    --sidebar-width: 260px;
    --header-height: 70px;

    --transition: all 0.3s ease;
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 15px 30px rgba(0, 0, 0, 0.15);
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--gray-800);
    background-color: #f2f0ff;
    overflow-x: hidden;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   GLOBAL SCROLLBAR (Glassmorphism)
   ============================================ */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

/* Chrome, Edge, Safari */
*::-webkit-scrollbar {
    width: 2px;
    height: 2px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.4);
}

/* ============================================
   LAYOUT
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    background-color: var(--white);
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 20px 0;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-brand {
    padding: 0 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .logo {
    width: 40px;
    height: 40px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 20px;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    position: relative;
}

.sidebar-menu a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.sidebar-menu a.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--white);
}



.sidebar-menu a i {
    margin-right: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-menu .badge {
    margin-left: auto;
    background-color: var(--danger-color);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-section-title {
    padding: 20px 20px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

/* ============================================
   UTILITIES - GRADIENTS & BACKGROUNDS
   ============================================ */
.bg-gradient-primary {
    background: linear-gradient(135deg, #2a2a72 0%, #3d3d9a 100%);
    color: var(--white);
}

.bg-gradient-info {
    background: linear-gradient(135deg, #17a2b8 0%, #4dbdcf 100%);
    color: var(--white);
}

.bg-light-blue {
    background-color: #f2f5fc;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    display: none;
    /* Hide default header on chat page if needed, or we adapt it */
}

/* ============================================
   CHAT LAYOUT
   ============================================ */
.chat-layout {
    display: flex;
    height: calc(100vh - 40px);
    /* Adjust based on sidebar/padding */
    gap: 0;
    margin: -20px;
    background: #fff;
    overflow: hidden;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    background: #f8f9fa;
    min-width: 0;
}

.chat-header {
    background: #fff;
    padding: 15px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    padding: 25px 15px 25px 30px;
    /* Reduced right padding, increased left padding */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-bubble {
    max-width: 100%;
    /* Increased width */
    padding: 12px 20px;
    border-radius: 18px;
    position: relative;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 5px;
}

.message-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.message-group.incoming {
    align-items: flex-start;
}

.message-group.outgoing {
    align-items: flex-end;
}

.message-bubble.incoming {
    background: #fff;
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
}

.message-bubble.outgoing {
    background: linear-gradient(135deg, #2a2a72 0%, #3d3d9a 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble.internal {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.message-meta {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 4px;
}

.chat-input-area {
    background: #fff;
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.chat-input-wrapper {
    background: #f8f9fa;
    border-radius: 25px;
    padding: 5px 15px;
    /* Reduced vertical padding */
    display: flex;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-input-wrapper textarea {
    border: none;
    background: transparent;
    flex: 1;
    padding: 10px;
    resize: none;
    height: 44px;
    /* Fixed height for single line look initially */
    max-height: 100px;
    outline: none;
}

.chat-sidebar {
    width: 380px;
    background: #fff;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 25px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-section {
    padding: 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray-600);
    font-weight: 700;
    letter-spacing: 0.8px;
    margin-bottom: 15px;
    display: block;
}

/* Modern Select Styles */
.sidebar-section .form-select,
.sidebar-section .form-control {
    background-color: #f8f9fa;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--gray-800);
    transition: all 0.2s;
    width: 100%;
    /* Custom Arrow */
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z' fill='%236c757d'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.sidebar-section .form-select:hover,
.sidebar-section .form-control:hover {
    background-color: #e9ecef;
}

.sidebar-section .form-select:focus,
.sidebar-section .form-control:focus {
    background-color: #fff;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(42, 42, 114, 0.1);
    outline: none;
}

/* File Attachment Styles */
.file-attachment {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: rgba(42, 42, 114, 0.1);
    color: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}

/* Override Main Content for Chat Page */
.page-content.chat-mode {
    padding: 0;
}

.header {
    background-color: var(--white);
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    margin: -20px -20px 30px;
    border-radius: 0;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 5px;
}

.header-title p {
    font-size: 13px;
    color: var(--gray-600);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 10px 40px 10px 15px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    width: 300px;
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 42, 114, 0.1);
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
}

.notification-icon {
    position: relative;
    padding: 10px;
    background-color: var(--gray-100);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.notification-icon:hover {
    background-color: var(--gray-200);
}

.notification-icon i {
    font-size: 20px;
    color: var(--gray-700);
}

.notification-icon .badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--danger-color);
    color: var(--white);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background-color: var(--gray-100);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background-color: var(--gray-200);
}

.user-menu img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

.user-menu .user-info {
    display: flex;
    flex-direction: column;
}

.user-menu .user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.user-menu .user-role {
    font-size: 12px;
    color: var(--gray-600);
}

/* ============================================
   CARDS & STATISTICS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.stat-card-title {
    font-size: 13px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card-icon {
    width: 45px;
    height: 45px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-card-icon.primary {
    background-color: rgba(42, 42, 114, 0.1);
    color: var(--primary-color);
}

.stat-card-icon.success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.stat-card-icon.warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

.stat-card-icon.danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.stat-card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 5px;
}

.stat-card-change {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-card-change.positive {
    color: var(--success-color);
}

.stat-card-change.negative {
    color: var(--danger-color);
}

.stat-card-change i {
    font-size: 12px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background-color: var(--gray-600);
    color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--gray-700);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background-color: #218838;
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline-primary:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

.form-label.required::after {
    content: '*';
    color: var(--danger-color);
    margin-left: 4px;
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--gray-400);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    font-family: var(--font-family);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 42, 114, 0.15);
}

.form-control:disabled {
    background-color: var(--gray-100);
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--gray-600);
}

.form-error {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 5px;
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background-color: var(--gray-100);
}

.table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

.table td {
    padding: 15px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: var(--gray-100);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.badge-primary {
    background-color: rgba(42, 42, 114, 0.1);
    color: var(--primary-color);
}

.badge-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.badge-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.badge-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.badge-info {
    background-color: rgba(23, 162, 184, 0.1);
    color: var(--info-color);
}

.badge-secondary {
    background-color: rgba(108, 117, 125, 0.1);
    color: var(--gray-600);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--gray-200);
    background-color: var(--gray-100);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    color: var(--gray-700);
    transition: var(--transition);
}

.pagination a:hover {
    background-color: var(--gray-100);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination .active {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 {
    margin-top: 10px;
}

.mt-2 {
    margin-top: 20px;
}

.mt-3 {
    margin-top: 30px;
}

.mb-1 {
    margin-bottom: 10px;
}

.mb-2 {
    margin-bottom: 20px;
}

.mb-3 {
    margin-bottom: 30px;
}

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

/* ============================================
   RESPONSIVE DESIGN & UTILITIES
   ============================================ */

/* Mobile Menu Toggle - HIDDEN BY DEFAULT */
.mobile-menu-toggle {
    display: none !important;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-700);
    cursor: pointer;
    padding: 5px;
}

/* Utilities */
.d-none {
    display: none !important;
}

.d-flex {
    display: flex !important;
}

.d-block {
    display: block !important;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

.bg-light {
    background-color: var(--light-color) !important;
}

.rounded-circle {
    border-radius: 50% !important;
}

.m-0 {
    margin: 0 !important;
}

.p-2 {
    padding: 0.5rem !important;
}

.text-muted {
    color: var(--gray-600) !important;
}

/* Desktop: Hide toggle, show flex utilities */
@media (min-width: 992px) {
    .d-md-none {
        display: none !important;
    }

    .d-md-block {
        display: block !important;
    }

    .d-md-flex {
        display: flex !important;
    }
}

/* Mobile/Tablet Styles */
@media (max-width: 991px) {
    .mobile-menu-toggle {
        display: block !important;
        /* Show only on mobile - Forced */
        margin-right: 15px;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .header {
        margin: -20px -20px 20px;
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .search-box input {
        width: 100%;
    }

    /* Hide desktop elements on mobile */
    .d-none.d-md-block {
        display: none !important;
    }

    .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.active {
        display: block;
    }
}