/* Diamond Softwares CRM - Glassmorphism Theme (Red accent + Dark/Light) */

:root,
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1a0a0a, #3b0a0a, #1f0f12);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    --accent: #ef4444;
    --accent-rgb: 239, 68, 68;
    --accent-secondary: #dc2626;
    --accent-pink: #f43f5e;
    --text-primary: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --green: #22c55e;
    --orange: #f59e0b;
    --red: #ef4444;
    --grey: #6b7280;
    --modal-bg: rgba(40, 15, 18, 0.95);
    --dropdown-bg: rgba(40, 15, 18, 0.95);
    --form-bg: rgba(255, 255, 255, 0.06);
    --form-focus-bg: rgba(255, 255, 255, 0.1);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --widget-border: rgba(255, 255, 255, 0.06);
    --select-option-bg: #2a1010;
    --btn-close-filter: invert(1);
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 16px;
    --radius-sm: 10px;
    --theme-toggle-bg: rgba(255, 255, 255, 0.12);
    --theme-toggle-icon: #fbbf24;
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f8f0f0, #fde8e8, #fff5f5);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(185, 28, 28, 0.12);
    --glass-shadow: 0 8px 32px rgba(185, 28, 28, 0.08);
    --accent: #dc2626;
    --accent-rgb: 220, 38, 38;
    --accent-secondary: #b91c1c;
    --accent-pink: #e11d48;
    --text-primary: #1f1212;
    --text-muted: rgba(31, 18, 18, 0.55);
    --green: #16a34a;
    --orange: #d97706;
    --red: #dc2626;
    --grey: #6b7280;
    --modal-bg: rgba(255, 255, 255, 0.98);
    --dropdown-bg: rgba(255, 255, 255, 0.98);
    --form-bg: rgba(255, 255, 255, 0.9);
    --form-focus-bg: #ffffff;
    --hover-bg: rgba(220, 38, 38, 0.06);
    --widget-border: rgba(0, 0, 0, 0.06);
    --select-option-bg: #ffffff;
    --btn-close-filter: none;
    --theme-toggle-bg: rgba(220, 38, 38, 0.1);
    --theme-toggle-icon: #b91c1c;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    transition: background 0.35s ease, color 0.25s ease;
}

/* ─── Glass Panel ─────────────────────────── */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.glass-alert {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(10px);
}

/* ─── Layout ──────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-left: none;
    border-top: none;
    border-bottom: none;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.brand-logo {
    width: auto;
    height: 42px;
    max-width: 140px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 4px 6px;
    flex-shrink: 0;
}

.brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
}

.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 1.1rem; }
.brand-text small { color: var(--text-muted); font-size: 0.75rem; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-item:hover { color: var(--text-primary); background: var(--hover-bg); }
.nav-item.active {
    color: var(--text-primary);
    background: rgba(var(--accent-rgb), 0.15);
    border: 1px solid rgba(var(--accent-rgb), 0.35);
}

.nav-item i { font-size: 1.15rem; width: 22px; text-align: center; }
.nav-divider { height: 1px; background: var(--glass-border); margin: 0.75rem 1rem; }
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--glass-border); }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title { flex: 1; margin-left: 0.5rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.content-area { padding: 1.5rem; flex: 1; }

.topbar-datetime {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
    margin-right: 0.5rem;
}
.topbar-datetime .date-line { font-size: 0.85rem; color: var(--text-muted); }
.topbar-datetime .time-line { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--theme-toggle-bg);
    color: var(--theme-toggle-icon);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
}
.theme-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.35);
    color: var(--accent);
}
.theme-toggle i { font-size: 1.15rem; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }
[data-theme="light"] .theme-toggle .icon-sun { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Notifications */
.notif-toggle { position: relative; color: var(--text-primary); }
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    border: 2px solid var(--bg-primary, transparent);
}
.notif-menu {
    width: 340px;
    max-width: calc(100vw - 1.5rem);
    padding: 0;
    overflow: hidden;
}
.notif-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
}
.notif-menu-header a { text-decoration: none; }
.notif-menu-body { max-height: 360px; overflow-y: auto; }
.notif-empty { padding: 1.25rem 1rem; text-align: center; }
.notif-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
}
.notif-item:hover { background: var(--hover-bg); color: inherit; }
.notif-item.unread { background: rgba(var(--accent-rgb), 0.08); }
.notif-item-title { font-weight: 700; font-size: 0.9rem; }
.notif-item-msg { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.notif-item-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.notif-menu-footer {
    padding: 0.65rem 1rem;
    text-align: center;
    border-top: 1px solid var(--glass-border);
}
.notif-menu-footer a { font-size: 0.85rem; font-weight: 600; text-decoration: none; }

/* Todo list page */
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--glass-border);
}
.todo-item:last-child { border-bottom: none; }
.todo-item.is-done .todo-title { text-decoration: line-through; opacity: 0.65; }
.todo-item.is-overdue { border-left: 3px solid var(--accent); }
.todo-title { font-weight: 700; }
.todo-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

.sidebar-toggle { color: var(--text-primary) !important; }

/* ─── Buttons ─────────────────────────────── */
.btn-gradient {
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    border: none;
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-gradient:hover {
    color: #fff;
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.45);
    transform: translateY(-1px);
}

.btn-glass {
    background: var(--form-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.btn-glass:hover { background: var(--hover-bg); color: var(--text-primary); }

.btn-outline-glass {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.btn-outline-glass:hover { background: var(--hover-bg); color: var(--text-primary); }

/* ─── Stat Cards ──────────────────────────── */
.stat-card {
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    opacity: 0.15;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 4px;
}

.stat-card.accent-blue .stat-value,
.stat-card.accent-red .stat-value { color: var(--accent); }
.stat-card.accent-purple .stat-value { color: var(--accent-secondary); }
.stat-card.accent-pink .stat-value { color: var(--accent-pink); }
.stat-card.accent-green .stat-value { color: var(--green); }
.stat-card.accent-orange .stat-value { color: var(--orange); }

/* ─── Badges ──────────────────────────────── */
.badge-green, .badge-orange, .badge-red, .badge-grey, .badge-purple, .badge-blue {
    padding: 0.3em 0.7em;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-green { background: rgba(34,197,94,0.2); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.badge-orange { background: rgba(245,158,11,0.2); color: var(--orange); border: 1px solid rgba(245,158,11,0.3); }
.badge-red { background: rgba(var(--accent-rgb),0.2); color: var(--red); border: 1px solid rgba(var(--accent-rgb),0.3); }
.badge-grey { background: rgba(107,114,128,0.2); color: var(--grey); border: 1px solid rgba(107,114,128,0.3); }
.badge-purple { background: rgba(var(--accent-rgb),0.18); color: var(--accent-secondary); border: 1px solid rgba(var(--accent-rgb),0.3); }
.badge-blue { background: rgba(var(--accent-rgb),0.2); color: var(--accent); border: 1px solid rgba(var(--accent-rgb),0.35); }

.badge-pulse::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Tables ──────────────────────────────── */
.table-glass {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--glass-border);
    --bs-table-hover-bg: var(--hover-bg);
    --bs-table-striped-bg: transparent;
}

.table-glass thead th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
}

.table-glass tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.9rem;
}

/* ─── Forms ───────────────────────────────── */
.form-control, .form-select {
    background: var(--form-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
}

.form-control:focus, .form-select:focus {
    background: var(--form-focus-bg);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }
.form-select option { background: var(--select-option-bg); color: var(--text-primary); }
.form-label { color: var(--text-muted); font-weight: 500; font-size: 0.85rem; margin-bottom: 0.35rem; }

.input-group-text {
    background: var(--form-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

/* ─── Login Page ──────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

.login-theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    animation: fadeSlideIn 0.6s ease;
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: block;
    width: 260px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 1rem;
    object-fit: contain;
    background: #fff;
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.login-brand .brand-icon {
    width: 64px; height: 64px;
    margin: 0 auto 1rem;
    font-size: 1.8rem;
}

.login-brand h2 { font-weight: 800; margin-bottom: 0.25rem; }
.login-brand p { color: var(--text-muted); font-size: 0.9rem; }

/* ─── Widgets ─────────────────────────────── */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.widget-header h5 { font-weight: 700; margin: 0; font-size: 1rem; }

.widget-list { list-style: none; padding: 0; margin: 0; }
.widget-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--widget-border);
    font-size: 0.88rem;
}
.widget-list li:last-child { border-bottom: none; }

/* ─── Service Tags ──────────────────────────── */
.service-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin: 1px;
}

/* ─── Tabs ────────────────────────────────── */
.nav-tabs-glass {
    border-bottom: 1px solid var(--glass-border);
    gap: 4px;
}

.nav-tabs-glass .nav-link {
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-tabs-glass .nav-link:hover { color: var(--text-primary); background: var(--hover-bg); }
.nav-tabs-glass .nav-link.active {
    color: var(--text-primary);
    background: rgba(var(--accent-rgb), 0.12);
    border-bottom: 2px solid var(--accent);
}

/* ─── Modals ──────────────────────────────── */
.modal-content {
    background: var(--modal-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.modal-header { border-bottom: 1px solid var(--glass-border); }
.modal-footer { border-top: 1px solid var(--glass-border); }
.btn-close { filter: var(--btn-close-filter); }

.glass-dropdown {
    background: var(--dropdown-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}

.glass-dropdown .dropdown-item { color: var(--text-primary); }
.glass-dropdown .dropdown-item:hover { background: var(--hover-bg); }

/* ─── Animations ──────────────────────────── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeSlideIn 0.5s ease; }

/* ─── Chart Container ─────────────────────── */
.chart-container { position: relative; height: 300px; }

/* ─── Search Bar ──────────────────────────── */
.search-bar { max-width: 320px; }

/* ─── Detail Page ─────────────────────────── */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-meta { color: var(--text-muted); font-size: 0.9rem; }
.detail-meta span { margin-right: 1rem; }

/* ─── Empty State ─────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: 0.3; margin-bottom: 1rem; }

/* ─── Responsive ──────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
}

@media (max-width: 575.98px) {
    .content-area { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .topbar-datetime .date-line { font-size: 0.75rem; }
    .topbar-datetime .time-line { font-size: 0.85rem; }
}

/* ─── Font weight utilities ───────────────── */
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

/* ─── Print ───────────────────────────────── */
@media print {
    body { background: #fff; color: #000; }
    .sidebar, .topbar { display: none !important; }
    .main-content { margin-left: 0; }
    .glass-card, .glass-panel { background: #fff; border: 1px solid #ddd; box-shadow: none; }
}

/* ─── Pagination ──────────────────────────── */
.page-link {
    background: var(--form-bg);
    border-color: var(--glass-border);
    color: var(--text-muted);
}
.page-link:hover { background: var(--hover-bg); color: var(--text-primary); }
.page-item.active .page-link {
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    border-color: transparent;
    color: #fff;
}

/* ─── Text utilities ──────────────────────── */
.text-muted { color: var(--text-muted) !important; }
a { color: var(--accent); }
a:hover { color: var(--accent-secondary); }

/* ─── Payment collect items ───────────────── */
.pending-item {
    padding: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.pending-item:hover, .pending-item.selected {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
}
.pending-item input[type="checkbox"] { accent-color: var(--accent); }
