/* ========================================
   CALM ENTERPRISE DESIGN - ITFLOW CLIENT PORTAL
   Design System: Calm Indigo (Stable, Accessible, Consistent)
   ======================================== */

:root {
    /* Calm Indigo Base Colors */
    --bg: #EEF2F7;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --surface-elevated: #FFFFFF;
    --border: #E2E8F0;
    --text: #0F172A;
    --text-muted: #475569;
    
    /* Primary Colors */
    --primary: #4F5BD5;
    --primary-hover: #3F4BC7;
    --primary-soft: rgba(79, 91, 213, 0.10);
    --focus-ring: rgba(79, 91, 213, 0.40);
    
    /* Legacy compatibility (mapped to new tokens) */
    --primary-color: #4F5BD5;
    --primary-hover: #3F4BC7;
    --primary-light: rgba(79, 91, 213, 0.10);
    --primary-dark: #3F4BC7;
    
    /* Accent Colors (reduced usage) */
    --accent-purple: #8B5CF6;
    --accent-blue: #3B82F6;
    --accent-teal: #14B8A6;
    
    /* Status Colors */
    --success: #16A34A;
    --success-soft: rgba(22, 163, 74, 0.10);
    --warning: #D97706;
    --warning-soft: rgba(217, 119, 6, 0.12);
    --danger: #DC2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --info: #0284C7;
    --info-soft: rgba(2, 132, 199, 0.10);
    
    /* Legacy status colors (mapped to new tokens) */
    --success-color: #16A34A;
    --success-light: rgba(22, 163, 74, 0.10);
    --warning-color: #D97706;
    --warning-light: rgba(217, 119, 6, 0.12);
    --danger-color: #DC2626;
    --danger-light: rgba(220, 38, 38, 0.10);
    --info-color: #0284C7;
    --info-light: rgba(2, 132, 199, 0.10);
    
    /* Neutrals (Slate palette) */
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    
    /* Shadows (reduced to 2 levels for calm design) */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.12);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.15);
    --shadow-lg: 0 10px 24px rgba(15, 23, 42, 0.18);
    --shadow-xl: 0 16px 32px rgba(15, 23, 42, 0.20);
    --shadow-2xl: 0 16px 32px rgba(15, 23, 42, 0.20);
    
    /* Transitions (reduced duration for calm UX) */
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius (consistent 10-12px) */
    --radius-sm: 0.5rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.75rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 0.75rem;
}

/* ========================================
   GLOBAL ANIMATIONS
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* ========================================
   CALM NAVBAR STYLING (SOLID BACKGROUND)
   ======================================== */

.navbar-dark.bg-dark {
    background: var(--gray-900) !important;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition-fast);
    position: relative;
    z-index: 1030;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    transition: var(--transition-fast);
    color: var(--primary);
}

.navbar-brand:hover {
    opacity: 0.85;
}

.nav-link {
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
    padding: 0.5rem 1rem !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: var(--transition-base);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 80%;
}

.nav-link:hover {
    color: var(--primary) !important;
}

.nav-link:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.dropdown-menu {
    border: none;
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    margin-top: 0.5rem;
    animation: slideInDown 0.3s ease-out;
    background: white;
}

.dropdown-item {
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    transition: var(--transition-fast);
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--surface-2);
    color: var(--primary);
}

.dropdown-item:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: -2px;
}

.dropdown-item i {
    width: 20px;
}

/* ========================================
   BODY AND BACKGROUND
   ======================================== */

body {
    background-color: var(--bg) !important;
}

.content-wrapper,
.main-content {
    background-color: var(--bg) !important;
}

/* Container max-width for wide screens */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

@media (min-width: 1600px) {
    .container {
        max-width: 1520px;
    }
}

@media (min-width: 1920px) {
    .container {
        max-width: 1720px;
    }
}

/* ========================================
   MODERN CARD STYLING
   ======================================== */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition-fast);
    overflow: hidden;
    background: var(--surface-elevated);
}

.card:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-md);
}

a.card {
    text-decoration: none;
    display: block;
}

a.card:hover {
    text-decoration: none;
}

.card-header {
    background: var(--gray-50);
    color: var(--text) !important;
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

.card-title {
    color: var(--text) !important;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.card-body {
    padding: 1rem;
    background: white;
}

.card-body .h4 {
    font-weight: 700;
    font-size: 1.75rem;
    margin: 0;
}

/* Stat cards specifically - even more compact */
.stat-card-danger .card-body,
.stat-card-primary .card-body,
.stat-card-success .card-body,
.stat-card-neutral .card-body {
    padding: 0.875rem 1rem;
}

/* Special Card Variants */
.card.text-dark .card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-blue));
}

.card .text-danger {
    color: var(--danger-color) !important;
    text-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

/* Dashboard Cards Grid */
.row .col-sm-3 {
    margin-bottom: 1.5rem;
}

/* ========================================
   STABLE BUTTON STYLING (NO LAYOUT SHIFT)
   ======================================== */

.btn {
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 0.625rem 1.5rem;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    letter-spacing: -0.025em;
}

.btn:hover {
    box-shadow: var(--shadow-sm);
}

.btn:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.btn:active {
    box-shadow: none;
}

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

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

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-2);
    border-color: var(--gray-300);
}

/* Outline button variants for filters and secondary actions */
.btn-outline-primary {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

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

.btn-outline-danger {
    background: var(--surface);
    border-color: var(--danger);
    color: var(--danger);
    font-weight: 600;
}

.btn-outline-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger);
}

.btn-outline-success {
    background: var(--surface);
    border-color: var(--success);
    color: var(--success);
    font-weight: 600;
}

.btn-outline-success:hover {
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--success);
}

.btn-outline-secondary {
    background: var(--surface);
    border-color: var(--gray-400);
    color: var(--text-muted);
    font-weight: 600;
}

.btn-outline-secondary:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--gray-500);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803D;
    border-color: #15803D;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #B91C1C;
    border-color: #B91C1C;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #B45309;
    border-color: #B45309;
}

.btn-info {
    background: var(--info);
    border-color: var(--info);
    color: white;
}

.btn-info:hover {
    background: #0369A1;
    border-color: #0369A1;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
}

/* ========================================
   MODERN TABLE STYLING
   ======================================== */

.table {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

.table thead {
    background: var(--gray-50);
    color: var(--text);
    border-bottom: 2px solid var(--border);
}

.table thead th {
    border: none !important;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 1rem 1.25rem;
}

.table tbody tr {
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--gray-100);
}

.table tbody tr:hover {
    background: var(--surface-2);
    cursor: pointer;
}

.table tbody td {
    padding: 1rem 1.25rem;
    border: none !important;
    vertical-align: middle;
}

.table tbody tr:last-child {
    border-bottom: none;
}

/* Remove dark borders */
.table.border-dark,
.table-bordered {
    border: none !important;
}

/* ========================================
   MODERN BADGE STYLING
   ======================================== */

.badge {
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    border: 1px solid;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(22, 163, 74, 0.25);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: rgba(217, 119, 6, 0.25);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.25);
}

.badge-info {
    background: var(--info-soft);
    color: var(--info);
    border-color: rgba(2, 132, 199, 0.25);
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(79, 91, 213, 0.25);
}

.badge-secondary {
    background: var(--surface-2);
    color: var(--text-muted);
    border-color: var(--border);
}

/* ========================================
   STABLE FORM STYLING (NO LAYOUT SHIFT)
   ======================================== */

.form-control {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    transition: var(--transition-fast);
    background: var(--surface);
    color: var(--text);
    line-height: 1.5;
}

.form-control option {
    color: var(--text);
    background: var(--surface);
    padding: 0.5rem;
}

select.form-control {
    height: auto;
    padding: 0.625rem 1rem;
}

.form-control:focus {
    border-color: var(--primary);
    outline: 2px solid var(--focus-ring);
    outline-offset: 0;
    box-shadow: none;
    color: var(--text);
}

.input-group-text {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.input-group:focus-within .input-group-text {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.input-group .form-control {
    border-left: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

/* ========================================
   WELCOME SECTION STYLING
   ======================================== */

.img-circle {
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    border: 3px solid white;
    transition: var(--transition-fast);
}

.img-circle:hover {
    box-shadow: var(--shadow-md);
}

.fa-stack {
    transition: var(--transition-fast);
}

.fa-stack:hover {
    opacity: 0.85;
}

/* ========================================
   ALERT STYLING
   ======================================== */

.alert {
    border: none;
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-md);
    animation: slideInDown 0.4s ease-out;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-color);
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-color);
    border-left: 4px solid var(--info-color);
}

/* ========================================
   MODAL STYLING
   ======================================== */

.modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
}

.modal-header {
    background: var(--gray-50);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    border: none;
    padding: 1.5rem;
    background: var(--gray-50);
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

@media (max-width: 575.98px) {
  .btn-responsive {
    display: block;
    width: 100%;
  }
  
  .card {
    margin-bottom: 1rem;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
}

@media (min-width: 576px) {
  .btn-responsive {
    display: inline-block;
    width: auto;
  }
}

/* ========================================
   DRAG HANDLE
   ======================================== */

.drag-handle {
    cursor: grab !important;
    transition: var(--transition-fast);
}

.drag-handle:active {
    cursor: grabbing !important;
    transform: scale(1.05);
}

.drag-handle:hover {
    opacity: 0.8;
}

/* ========================================
   LOADING STATES & ANIMATIONS
   ======================================== */

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.shimmer {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-soft {
    box-shadow: var(--shadow-md);
}

.shadow-strong {
    box-shadow: var(--shadow-xl);
}

.rounded-modern {
    border-radius: var(--radius-xl);
}

.transition-smooth {
    transition: var(--transition-base);
}

/* ========================================
   PAGE LOAD ANIMATIONS
   ======================================== */

body.modern-portal {
    animation: fadeIn 0.6s ease-out;
}

.container > .row {
    animation: fadeIn 0.5s ease-out;
}

/* Remove staggered card delays for calm UX */
.card {
    animation: fadeIn 0.5s ease-out;
}

/* ========================================
   LINK STYLING
   ======================================== */

a {
    transition: var(--transition-fast);
}

a:hover {
    text-decoration: none;
}

/* ========================================
   BREADCRUMB MODERNIZATION
   ======================================== */

.breadcrumb {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--gray-400);
}

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

/* ========================================
   HR MODERNIZATION
   ======================================== */

hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 2rem 0;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ========================================
   SELECTION STYLING
   ======================================== */

::selection {
    background: var(--primary-soft);
    color: var(--primary);
}

::-moz-selection {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ========================================
   FOCUS VISIBLE STYLING
   ======================================== */

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .navbar, .btn, footer {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid var(--gray-300) !important;
    }
}

/* Footer Links */
.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    margin-right: 1rem;
    transition: var(--transition-fast);
}

.footer-link:hover {
    color: var(--primary);
    text-decoration: none;
}

/* Dashboard Ticket Items */
.ticket-item {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    transition: var(--transition-fast);
}

.ticket-item:hover {
    background: var(--surface-2) !important;
}

.ticket-link:hover {
    text-decoration: underline !important;
}

/* ========================================
   DASHBOARD COMPONENT CLASSES
   ======================================== */

/* Dashboard icon box - replaces inline gradient icon styles */
.dashboard-icon-box {
    width: 60px;
    height: 60px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

/* Dashboard stat cards with status-specific border */
.stat-card-danger {
    border-left: 4px solid var(--danger) !important;
    background: linear-gradient(to right, rgba(220, 38, 38, 0.03), transparent 120px), var(--surface-elevated) !important;
}

.stat-card-primary {
    border-left: 4px solid var(--primary) !important;
    background: linear-gradient(to right, rgba(79, 91, 213, 0.03), transparent 120px), var(--surface-elevated) !important;
}

.stat-card-success {
    border-left: 4px solid var(--success) !important;
    background: linear-gradient(to right, rgba(22, 163, 74, 0.03), transparent 120px), var(--surface-elevated) !important;
}

.stat-card-neutral {
    border-left: 4px solid var(--gray-600) !important;
    background: linear-gradient(to right, rgba(100, 116, 139, 0.03), transparent 120px), var(--surface-elevated) !important;
}

/* Icon boxes for stat cards */
.icon-box {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-box-danger {
    background: var(--danger-soft);
}

.icon-box-danger i {
    color: var(--danger);
}

.icon-box-primary {
    background: var(--primary-soft);
}

.icon-box-primary i {
    color: var(--primary);
}

.icon-box-success {
    background: var(--success-soft);
}

.icon-box-success i {
    color: var(--success);
}

.icon-box-neutral {
    background: var(--surface-2);
}

.icon-box-neutral i {
    color: var(--text-muted);
}

/* Stat card typography */
.stat-label {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-value {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0;
    line-height: 1.2;
}

.stat-value-danger {
    color: var(--danger);
}

.stat-value-primary {
    color: var(--primary);
}

.stat-value-success {
    color: var(--success);
}

.stat-value-neutral {
    color: var(--gray-700);
}

/* Dashboard page title */
.dashboard-title {
    font-weight: 700;
    color: var(--text);
}

/* ========================================
   TICKET DETAIL PAGE STYLES
   ======================================== */

/* Ticket content area styling */
.ticket-content {
    line-height: 1.6;
    color: var(--text);
}

.ticket-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin: 1rem 0;
}

.ticket-content table {
    width: 100%;
    margin: 1rem 0;
}

.ticket-content pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    overflow-x: auto;
}

.ticket-content code {
    background: var(--surface-2);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

/* Reply cards styling */
.reply-card {
    border-left: 3px solid var(--primary);
    margin-bottom: 1.5rem;
}

.reply-card .card-header {
    background: var(--surface-2);
}

/* ========================================
   ACCESSIBILITY: MOTION REDUCTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .card {
        animation: none !important;
    }
    
    body.modern-portal,
    body.modern-portal .container > .row {
        animation: none !important;
    }
}
