/* --- 1. CSS VARIABLES & RESET --- */
:root {
    /* Palette */
    --primary: #0F4C81; /* Enterprise Blue */
    --primary-dark: #0a355c;
    --secondary: #F5F5F5; /* Light Gray */
    --white: #ffffff;
    --text-main: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    
    /* Status Colors */
    --success: #4CAF50; /* Green */
    --warning: #FF9800; /* Orange */
    --danger: #F44336; /* Red */
    --info: #2196F3; /* Blue */
    --archived: #9E9E9E;

    /* Spacing & UI */
    --sidebar-width: 250px;
    --header-height: 60px;
    --radius: 4px;
    --shadow: 0 2px 5px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body { background-color: var(--secondary); color: var(--text-main); height: 100vh; display: flex; overflow: hidden; }

/* --- 2. LAYOUT STRUCTURE --- */
/* Sidebar */
aside {
    width: var(--sidebar-width);
    background-color: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    transition: 0.3s;
    z-index: 100;
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 1.2rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    letter-spacing: 0.5px;
}
.brand i { margin-right: 10px; color: #64b5f6; }

nav ul { list-style: none; padding-top: 20px; }
nav li { padding: 12px 20px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; opacity: 0.8; }
nav li:hover, nav li.active { background-color: rgba(255,255,255,0.1); opacity: 1; border-left: 4px solid var(--warning); }
nav li i { width: 30px; text-align: center; margin-right: 10px; }

.user-mini {
    margin-top: auto;
    padding: 20px;
    background-color: var(--primary-dark);
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}
.user-mini img { width: 35px; height: 35px; border-radius: 50%; margin-right: 10px; border: 2px solid var(--white); }

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
header {
    height: var(--header-height);
    background-color: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}
.page-title { font-size: 1.2rem; font-weight: 600; color: var(--primary); }
.header-actions button {
    background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-light); margin-left: 15px; position: relative;
}
.header-actions button:hover { color: var(--primary); }
.badge {
    position: absolute; top: -5px; right: -5px; background: var(--danger); color: white; font-size: 0.6rem; padding: 2px 5px; border-radius: 10px;
}

/* Content Scroll Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* --- 3. COMPONENTS & UTILITIES --- */
/* Cards */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--secondary); padding-bottom: 10px; }
.card-title { font-weight: 600; color: var(--primary); }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-secondary { background-color: var(--white); border: 1px solid var(--border); color: var(--text-main); }
.btn-secondary:hover { background-color: var(--secondary); }
.btn-danger { background-color: var(--danger); color: white; }
.btn-sm { padding: 4px 8px; font-size: 0.8rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--secondary); font-size: 0.9rem; }
th { background-color: #fafafa; color: var(--text-light); font-weight: 600; }
tr:hover { background-color: #f9f9f9; }

/* Status Badges */
.badge-pill { padding: 4px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.bg-low { background-color: #e8f5e9; color: #2e7d32; }
.bg-medium { background-color: #e3f2fd; color: #1565c0; }
.bg-high { background-color: #fff3e0; color: #ef6c00; }
.bg-critical { background-color: #ffebee; color: #c62828; }
.bg-open { background-color: #e3f2fd; color: #1976d2; }
.bg-progress { background-color: #fff3e0; color: #f57c00; }
.bg-resolved { background-color: #e8f5e9; color: #388e3c; }
.bg-closed { background-color: #f5f5f5; color: #616161; }

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9rem; }
.form-control { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; }
.form-control:focus { outline: none; border-color: var(--primary); }
.row { display: flex; gap: 20px; }
.col { flex: 1; }

/* Grid Layouts */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 20px; }

/* --- 4. VIEWS --- */
.view-section { display: none; animation: fadeIn 0.3s ease; }
.view-section.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Dashboard KPIs */
.kpi-card { display: flex; align-items: center; justify-content: space-between; }
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.kpi-label { color: var(--text-light); font-size: 0.9rem; }
.kpi-icon { font-size: 2rem; opacity: 0.2; }

/* Login Screen */
#login-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #001f3f 100%);
    display: flex; justify-content: center; align-items: center; z-index: 9999;
}
.login-box { background: white; padding: 40px; border-radius: 8px; width: 350px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.login-box h2 { margin-bottom: 20px; color: var(--primary); }
.login-box input { margin-bottom: 15px; width: 100%; }
.login-box button { width: 100%; }

/* Ticket Detail Split */
.ticket-detail-layout { display: flex; gap: 20px; height: calc(100vh - 140px); }
.ticket-main { flex: 2; overflow-y: auto; padding-right: 10px; }
.ticket-sidebar { flex: 1; display: flex; flex-direction: column; gap: 20px; }

.timeline-item { border-left: 2px solid var(--border); padding-left: 20px; padding-bottom: 20px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -6px; top: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline-date { font-size: 0.8rem; color: var(--text-light); }

/* Responsive */
@media (max-width: 768px) {
    aside { position: absolute; left: -250px; height: 100%; }
    aside.open { left: 0; }
    .grid-4, .grid-2 { grid-template-columns: 1fr; }
    .ticket-detail-layout { flex-direction: column; height: auto; }
    .content-area { padding: 10px; }
}