:root {
    --bg-color: #f4f5f7;
    --card-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --primary-dark: #1f2937;
    --accent-green: #6df0b2;
    --border-color: #e5e7eb;
}

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

h1, h2, h3, h4 { margin: 0; }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }
.font-bold { font-weight: 600; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }

/* Login Container */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
.login-card {
    background: var(--card-bg); padding: 2rem; border-radius: 12px;
    border: 1px solid var(--border-color); width: 100%; max-width: 380px; box-sizing: border-box;
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; font-weight: 500; color: var(--text-main); }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
    width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 8px;
    box-sizing: border-box; font-family: inherit; font-size: 0.95rem;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary-dark); }

.btn {
    width: 100%; padding: 0.875rem; background-color: var(--primary-dark); color: white;
    border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer;
    text-align: center; text-decoration: none; box-sizing: border-box; display: inline-block;
}
.btn-green { background-color: #059669; }

/* Desktop Sidebar */
.sidebar { display: none; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; width: 100%; }

/* Mobile Bottom Navigation */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; width: 100%;
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 0.5rem;
    z-index: 1000;
    box-sizing: border-box;
}
.nav-item {
    flex: 1; text-align: center; color: #4b5563;
    text-decoration: none; font-size: 0.75rem; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 0.5rem 0;
    border-radius: 24px;
    margin: 0 4px;
    transition: background-color 0.2s;
}
.nav-item.active {
    background-color: #6ee7b7;
    color: #064e3b;
}
.nav-icon {
    margin-bottom: 2px;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
}
.nav-icon svg {
    width: 20px; height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Dashboard Headers & Cards */
.top-header {
    position: sticky; top: 0; z-index: 999;
    display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem;
    background: var(--bg-color); border-bottom: 1px solid var(--border-color);
}
.main-content {
    padding: 1.5rem; padding-bottom: 90px; flex: 1; max-width: 800px; margin: 0 auto; width: 100%; box-sizing: border-box;
}
.stats-grid { display: flex; flex-direction: column; }
.stat-card {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    padding: 1.5rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center;
}
.stat-card .value { font-size: 2rem; font-weight: bold; margin-top: 0.5rem; }
.stat-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; }
.bg-blue-light { background: #eff6ff; color: #1e3a8a; }
.bg-orange-light { background: #fff7ed; color: #9a3412; }
.bg-green-light { background: #ecfdf5; color: #065f46; }

/* Ticket List Item */
.ticket-item {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    padding: 1.25rem; margin-bottom: 1rem; border-left: 4px solid #dc2626; text-decoration: none; display: block; color: inherit;
}
.ticket-item.status-progress { border-left-color: #f59e0b; }
.ticket-item.status-resolved { border-left-color: #10b981; }

.badge { padding: 0.2rem 0.6rem; border-radius: 9999px; font-size: 0.7rem; font-weight: bold; display: inline-block; }
.badge-red { background: #fee2e2; color: #ef4444; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* Chat Bubbles */
.chat-container { margin-top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.chat-bubble-wrapper { display: flex; align-items: flex-start; gap: 0.75rem; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: #e5e7eb;
    display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 0.9rem; flex-shrink:0;
}
.chat-bubble { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 1rem; max-width: 85%; }
.chat-bubble.internal { background: #f9fafb; border: 1px solid #d1d5db; }
.chat-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.85rem; align-items: center; gap: 1rem; }
.chat-name { font-weight: 600; color: var(--text-main); }
.chat-time { color: var(--text-muted); font-size: 0.75rem; }

/* Reply Box */
.reply-box { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; margin-top: 1.5rem; }
.reply-tabs { display: flex; background: #f9fafb; border-bottom: 1px solid var(--border-color); }
.reply-tab { padding: 0.75rem 1.5rem; cursor: pointer; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
.reply-tab.active { background: var(--card-bg); color: var(--text-main); font-weight: 600; }
.reply-textarea { border: none; border-radius: 0; padding: 1rem; width: 100%; min-height: 100px; resize: vertical; }
.reply-textarea:focus { border: none; box-shadow: none; }

/* Responsive Desktop Rules */
@media (min-width: 768px) {
    body { flex-direction: row; }
    .bottom-nav { display: none; } /* Hide mobile nav */
    .sidebar {
        display: flex; flex-direction: column; width: 260px; background: var(--card-bg);
        border-right: 1px solid var(--border-color); height: 100vh; position: sticky; top: 0; padding: 1.5rem;
    }
    .sidebar-logo { font-size: 1.25rem; font-weight: bold; margin-bottom: 2rem; display: flex; align-items: center; gap: 10px; }
    .sidebar-item { 
        display: flex; align-items: center; gap: 10px; padding: 0.75rem 1rem; 
        color: var(--text-muted); text-decoration: none; border-radius: 8px; margin-bottom: 0.5rem; font-weight: 500;
    }
    .sidebar-item:hover { background: var(--bg-color); }
    .sidebar-item.active { background: var(--accent-green); color: var(--primary-dark); font-weight: 700; }
    
    .main-wrapper { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
    .main-content { padding-bottom: 2rem; max-width: 900px; width: 100%; margin: 0 auto; }
    .stats-grid { flex-direction: row; gap: 1.5rem; }
    .stat-card { flex: 1; margin-bottom: 0; }
    .login-card { max-width: 450px; }
}
