/**
 * e-Courts Helpdesk Platform Enterprise Design System
 * Theme tokens driven by PHP config / CSS Variables
 */

:root {
    --primary-color: #1b365d;
    --primary-hover: #132742;
    --secondary-color: #4a607a;
    --accent-color: #c59b27;
    --accent-hover: #a8841f;
    --sidebar-bg: #0d1e38;
    --sidebar-text: #e2e8f0;
    --sidebar-active-bg: rgba(197, 155, 39, 0.15);
    --sidebar-active-text: #f0c554;
    --topbar-bg: #ffffff;
    --topbar-border: #e2e8f0;
    --body-bg: #f4f6fa;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1);
    --radius-md: 10px;
    --radius-lg: 14px;
}

[data-theme="dark"] {
    --body-bg: #0f172a;
    --card-bg: #1e293b;
    --topbar-bg: #1e293b;
    --topbar-border: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --sidebar-bg: #090e1a;
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
}

body {
    background-color: var(--body-bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.animate-fade-in {
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
    *, ::after, ::before {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

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

/* Sidebar */
.app-sidebar {
    width: 270px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.app-sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    height: 72px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background-color: rgba(0,0,0,0.15);
}

.sidebar-brand-logo {
    max-height: 44px;
    max-width: 190px;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.app-sidebar.collapsed .sidebar-brand-logo {
    max-width: 40px;
}

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

.sidebar-nav-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.45);
    padding: 12px 14px 6px;
    margin: 0;
}

.sidebar-nav-item {
    margin-bottom: 4px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 12px;
}

.sidebar-nav-link i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    color: rgba(226, 232, 240, 0.7);
    transition: color 0.2s ease;
}

.sidebar-nav-link:hover {
    background-color: rgba(255,255,255,0.08);
    color: #ffffff;
}

.sidebar-nav-link:hover i {
    color: var(--accent-color);
}

.sidebar-nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    border-left: 3px solid var(--accent-color);
}

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

.app-sidebar.collapsed .sidebar-nav-text,
.app-sidebar.collapsed .sidebar-nav-title,
.app-sidebar.collapsed .badge {
    display: none !important;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
    background-color: rgba(0,0,0,0.12);
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

/* Topbar */
.app-topbar {
    height: 72px;
    background-color: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.topbar-search {
    max-width: 440px;
    width: 100%;
}

.topbar-search .form-control {
    background-color: var(--body-bg);
    border-color: var(--border-color);
    font-size: 13px;
    color: var(--text-main);
}

.topbar-search .input-group .btn {
    border-color: var(--border-color);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Cards & Widgets */
.card-judicial {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-judicial:hover {
    box-shadow: var(--shadow-md);
}

.kpi-card {
    position: relative;
    overflow: hidden;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Status Badges */
.badge-status-open,
.badge.badge-status-open,
.badge.status-open,
.status-open {
    background-color: rgba(13, 110, 253, 0.12) !important;
    color: #0d6efd !important;
    border: 1px solid rgba(13, 110, 253, 0.25);
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-status-processing,
.badge.badge-status-processing,
.badge.status-processing,
.status-processing {
    background-color: rgba(253, 126, 20, 0.12) !important;
    color: #d97706 !important;
    border: 1px solid rgba(253, 126, 20, 0.25);
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-status-hold,
.badge.badge-status-hold,
.badge.status-hold,
.badge.status-on_hold,
.status-hold,
.status-on_hold {
    background-color: rgba(108, 117, 125, 0.12) !important;
    color: #495057 !important;
    border: 1px solid rgba(108, 117, 125, 0.25);
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-status-resolved,
.badge.badge-status-resolved,
.badge.status-resolved,
.status-resolved {
    background-color: rgba(25, 135, 84, 0.12) !important;
    color: #198754 !important;
    border: 1px solid rgba(25, 135, 84, 0.25);
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-status-closed,
.badge.badge-status-closed,
.badge.status-closed,
.status-closed {
    background-color: rgba(33, 37, 41, 0.12) !important;
    color: #212529 !important;
    border: 1px solid rgba(33, 37, 41, 0.25);
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-status-reopened,
.badge.badge-status-reopened,
.badge.status-reopened,
.status-reopened {
    background-color: rgba(220, 53, 69, 0.15) !important;
    color: #dc3545 !important;
    border: 1px solid rgba(220, 53, 69, 0.35);
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 20px;
    animation: pulseGlow 2s infinite;
}

/* Priority Badges */
.badge-priority-low,
.badge.badge-priority-low,
.badge.priority-low,
.priority-low {
    background-color: #e8f5e9 !important;
    color: #2e7d32 !important;
    border: 1px solid rgba(46, 125, 50, 0.3);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
}

.badge-priority-medium,
.badge.badge-priority-medium,
.badge.priority-medium,
.priority-medium {
    background-color: #e3f2fd !important;
    color: #1565c0 !important;
    border: 1px solid rgba(21, 101, 192, 0.3);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
}

.badge-priority-high,
.badge.badge-priority-high,
.badge.priority-high,
.priority-high {
    background-color: #fff3e0 !important;
    color: #e65100 !important;
    border: 1px solid rgba(230, 81, 0, 0.3);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
}

.badge-priority-critical,
.badge.badge-priority-critical,
.badge.priority-critical,
.priority-critical {
    background-color: #ffebee !important;
    color: #c62828 !important;
    border: 1px solid rgba(198, 40, 40, 0.3);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    animation: pulseGlow 1.8s infinite;
}

/* Conversation Thread */
.timeline-thread {
    position: relative;
    padding: 20px 0;
}

.message-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.message-card.internal-note {
    background-color: #fffdf5;
    border: 1px dashed #d97706;
}

[data-theme="dark"] .message-card.internal-note {
    background-color: #2b2413;
    border: 1px dashed #f59e0b;
}

.message-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0,0,0,0.015);
}

.message-body {
    padding: 20px;
    line-height: 1.65;
    font-size: 15px;
}

/* Drag and Drop File Zone */
.dropzone-judicial {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    background-color: rgba(248, 250, 252, 0.7);
    transition: all 0.25s ease;
}

.dropzone-judicial:hover,
.dropzone-judicial.dragover {
    border-color: var(--primary-color);
    background-color: rgba(27, 54, 93, 0.04);
}

/* Buttons */
.btn-judicial-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-judicial-primary:hover, .btn-judicial-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(27, 54, 93, 0.25);
}

.btn-judicial-accent {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: #ffffff;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: var(--radius-md);
}

.btn-judicial-accent:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #ffffff;
}

/* Sticky ticket sidebar properties panel */
.sticky-properties-panel {
    position: sticky;
    top: 92px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Modal Stacking & Backdrop Fix */
.modal-backdrop {
    z-index: 1050 !important;
}

.modal {
    z-index: 1060 !important;
}

.modal-dialog {
    z-index: 1065 !important;
}
