/* ============================================================
   PutraKop Live Chat System - Main Stylesheet
   Theme: Navy Blue Enterprise SaaS
   Version: 1.0.0
   ============================================================ */

/* ========== CSS Custom Properties ========== */
:root {
    /* Primary Colors */
    --color-primary: #1B2A4A;
    --color-primary-light: #2C3E6B;
    --color-primary-dark: #0F1A2E;
    --color-primary-rgb: 27, 42, 74;
    
    /* Secondary Colors */
    --color-secondary: #F5F7FA;
    --color-secondary-dark: #E5E7EB;
    
    /* Accent Colors */
    --color-accent: #3B82F6;
    --color-accent-hover: #2563EB;
    
    /* Status Colors */
    --color-success: #10B981;
    --color-success-light: #D1FAE5;
    --color-warning: #F59E0B;
    --color-warning-light: #FEF3C7;
    --color-danger: #EF4444;
    --color-danger-light: #FEE2E2;
    --color-info: #3B82F6;
    --color-info-light: #DBEAFE;
    
    /* Text Colors */
    --color-text-primary: #1F2937;
    --color-text-secondary: #6B7280;
    --color-text-muted: #9CA3AF;
    --color-text-white: #FFFFFF;
    
    /* Border Colors */
    --color-border: #E5E7EB;
    --color-border-light: #F3F4F6;
    
    /* Background Colors */
    --color-bg: #FFFFFF;
    --color-bg-secondary: #F9FAFB;
    --color-bg-hover: #F3F4F6;
    
    /* Sizing */
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --border-radius: 6px;
    --border-radius-lg: 8px;
    --border-radius-xl: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    
    /* Font */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========== CSS Reset ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-primary);
    background-color: var(--color-bg-secondary);
    min-height: 100vh;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

ul, ol {
    list-style: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    color: var(--color-text-primary);
    font-weight: 600;
}

h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

.text-sm { font-size: 12px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }

.text-muted { color: var(--color-text-secondary); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-info { color: var(--color-info); }
.text-white { color: var(--color-text-white); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ========== Layout ========== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary);
    color: var(--color-text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo img {
    height: 32px;
}

.sidebar-logo span {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-white);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.7);
    transition: all var(--transition-fast);
    cursor: pointer;
    gap: 12px;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-white);
}

.sidebar-nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text-white);
    border-left-color: var(--color-accent);
}

.sidebar-nav-item i, .sidebar-nav-item svg {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-content {
    flex: 1;
    padding: 24px;
}

/* ========== Cards ========== */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border-light);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.card-body {
    /* Content */
}

.card-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-light);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-secondary);
}

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

.btn-danger:hover:not(:disabled) {
    background: #DC2626;
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    height: 40px;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
    color: var(--color-text-muted);
}

textarea.form-control {
    height: auto;
    min-height: 80px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-error {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 4px;
}

.form-control.is-invalid {
    border-color: var(--color-danger);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-check-label {
    font-size: 14px;
    cursor: pointer;
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-bottom: 2px solid var(--color-border);
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-primary);
    vertical-align: middle;
}

.table tr:hover td {
    background: var(--color-bg-hover);
}

.table-striped tr:nth-child(even) td {
    background: var(--color-bg-secondary);
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-primary {
    background: var(--color-primary);
    color: var(--color-text-white);
}

.badge-success {
    background: var(--color-success-light);
    color: #065F46;
}

.badge-warning {
    background: var(--color-warning-light);
    color: #92400E;
}

.badge-danger {
    background: var(--color-danger-light);
    color: #991B1B;
}

.badge-info {
    background: var(--color-info-light);
    color: #1E40AF;
}

.badge-secondary {
    background: var(--color-secondary);
    color: var(--color-text-secondary);
}

/* ========== Alerts ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--color-success-light);
    border-color: #A7F3D0;
    color: #065F46;
}

.alert-warning {
    background: var(--color-warning-light);
    border-color: #FDE68A;
    color: #92400E;
}

.alert-danger {
    background: var(--color-danger-light);
    border-color: #FECACA;
    color: #991B1B;
}

.alert-info {
    background: var(--color-info-light);
    border-color: #93C5FD;
    color: #1E40AF;
}

.alert-dismissible {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 18px;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--color-bg);
    border-radius: var(--border-radius-xl);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 20px;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

/* ========== Dropdown ========== */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    min-width: 200px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--color-bg-hover);
    text-decoration: none;
}

.dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}

.page-item {
    display: inline;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text-primary);
    background: var(--color-bg);
    transition: all var(--transition-fast);
}

.page-link:hover {
    background: var(--color-bg-hover);
    text-decoration: none;
}

.page-item.active .page-link {
    background: var(--color-primary);
    color: var(--color-text-white);
    border-color: var(--color-primary);
}

.page-item.disabled .page-link {
    color: var(--color-text-muted);
    cursor: not-allowed;
    pointer-events: none;
}

/* ========== KPI Cards ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.kpi-icon.primary { background: rgba(var(--color-primary-rgb), 0.1); color: var(--color-primary); }
.kpi-icon.success { background: #D1FAE5; color: var(--color-success); }
.kpi-icon.warning { background: #FEF3C7; color: var(--color-warning); }
.kpi-icon.danger { background: #FEE2E2; color: var(--color-danger); }

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.kpi-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.kpi-info {
    text-align: right;
}

.kpi-change {
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
}

.kpi-change.up { color: var(--color-success); }
.kpi-change.down { color: var(--color-danger); }

/* ========== Status Indicators ========== */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.online { background: var(--color-success); }
.status-dot.away { background: var(--color-warning); }
.status-dot.offline { background: var(--color-text-muted); }
.status-dot.busy { background: var(--color-danger); }

/* ========== Avatar ========== */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-secondary);
}

.avatar-sm { width: 28px; height: 28px; }
.avatar-lg { width: 48px; height: 48px; }
.avatar-xl { width: 64px; height: 64px; }

/* ========== Loading ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* ========== Utility Classes ========== */
.d-flex { display: flex; }
.d-grid { display: grid; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }

.m-0 { margin: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-0 { padding: 0; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.p-24 { padding: 24px; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

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

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

.border { border: 1px solid var(--color-border); }
.border-0 { border: none; }

.bg-white { background: var(--color-bg); }
.bg-secondary { background: var(--color-bg-secondary); }

.cursor-pointer { cursor: pointer; }

.overflow-hidden { overflow: hidden; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state img, .empty-state svg {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    
    .page-content {
        padding: 16px;
    }
    
    .modal {
        max-width: 100%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        padding: 0 12px;
    }
    
    .page-content {
        padding: 12px;
    }
}
