/* ============================================
   HK Hotel System - Main Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #6366f1;
  --topbar-bg: #ffffff;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --radius: .75rem;
  --radius-sm: .5rem;
  --radius-lg: 1rem;
  --transition: all .2s ease;
  /* Status colors */
  --vacant: #22c55e;
  --vacant-bg: #f0fdf4;
  --vacant-border: #bbf7d0;
  --occupied: #ef4444;
  --occupied-bg: #fef2f2;
  --occupied-border: #fecaca;
  --cleaning: #f59e0b;
  --cleaning-bg: #fffbeb;
  --cleaning-border: #fde68a;
  --maintenance: #94a3b8;
  --maintenance-bg: #f8fafc;
  --maintenance-border: #cbd5e1;
  --sidebar-width: 260px;
  --topbar-h: 64px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--body-bg); color: var(--text-primary); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
  overflow: hidden;
}
.sidebar-logo {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo svg { width: 32px; height: 32px; color: var(--primary-light); flex-shrink: 0; }
.sidebar-logo-text { color: #fff; }
.sidebar-logo-text h2 { font-size: .95rem; font-weight: 700; line-height: 1.2; }
.sidebar-logo-text span { font-size: .7rem; color: var(--text-muted); }
.sidebar-menu { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar-section { padding: .5rem 1.5rem .25rem; font-size: .65rem; font-weight: 600; letter-spacing: .08em; color: #475569; text-transform: uppercase; }
.sidebar-item { display: flex; align-items: center; gap: .75rem; padding: .65rem 1.5rem; color: #94a3b8; font-size: .875rem; font-weight: 500; cursor: pointer; transition: var(--transition); border-left: 3px solid transparent; }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item:hover { background: var(--sidebar-hover); color: #fff; border-left-color: var(--primary-light); }
.sidebar-item.active { background: rgba(99,102,241,.15); color: #fff; border-left-color: var(--primary); }
.sidebar-item .badge-count { margin-left: auto; background: var(--primary); color: #fff; font-size: .65rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px; }
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-user { display: flex; align-items: center; gap: .75rem; }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { color: #fff; font-size: .8rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { color: #64748b; font-size: .7rem; }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h); background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 90;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-toggle { background: none; border: none; cursor: pointer; padding: .5rem; border-radius: var(--radius-sm); color: var(--text-secondary); display: flex; }
.topbar-toggle:hover { background: var(--body-bg); }
.topbar-toggle svg { width: 22px; height: 22px; }
.topbar-breadcrumb { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); }
.topbar-breadcrumb .current { color: var(--text-primary); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-notif { position: relative; }
.notif-btn { background: none; border: none; cursor: pointer; padding: .5rem; border-radius: var(--radius-sm); color: var(--text-secondary); display: flex; position: relative; }
.notif-btn:hover { background: var(--body-bg); color: var(--primary); }
.notif-btn svg { width: 22px; height: 22px; }
.notif-badge { position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; background: var(--occupied); color: #fff; font-size: .6rem; font-weight: 700; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.notif-dropdown { position: absolute; right: 0; top: calc(100% + .5rem); width: 320px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200; display: none; }
.notif-dropdown.show { display: block; animation: fadeInDown .2s ease; }
.notif-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.notif-header h4 { font-size: .875rem; font-weight: 600; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: .75rem; transition: var(--transition); }
.notif-item:hover { background: var(--body-bg); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: .4rem; }
.notif-text { font-size: .8rem; color: var(--text-secondary); }
.notif-time { font-size: .7rem; color: var(--text-muted); margin-top: .2rem; }
.notif-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: .875rem; }
.topbar-profile { display: flex; align-items: center; gap: .6rem; cursor: pointer; padding: .4rem .75rem; border-radius: var(--radius-sm); transition: var(--transition); border: none; background: none; }
.topbar-profile:hover { background: var(--body-bg); }
.topbar-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.topbar-name { font-size: .85rem; font-weight: 600; color: var(--text-primary); }

/* ---- Main Content ---- */
.main-content { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.page-content { padding: 1.5rem; flex: 1; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.page-header p { font-size: .875rem; color: var(--text-secondary); margin-top: .2rem; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem; transition: var(--transition); border: 1px solid var(--border); }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.total { background: #ede9fe; color: var(--primary); }
.stat-icon.vacant { background: var(--vacant-bg); color: var(--vacant); }
.stat-icon.occupied { background: var(--occupied-bg); color: var(--occupied); }
.stat-icon.cleaning { background: var(--cleaning-bg); color: var(--cleaning); }
.stat-icon.maintenance { background: var(--maintenance-bg); color: var(--maintenance); }
.stat-info { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-secondary); margin-top: .25rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Cards ---- */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ---- Room Grid ---- */
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.room-card { border-radius: var(--radius); padding: 1rem; border: 2px solid var(--border); background: var(--card-bg); cursor: pointer; transition: var(--transition); position: relative; overflow: hidden; }
.room-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.room-card.vacant { border-color: var(--vacant-border); background: var(--vacant-bg); }
.room-card.vacant::before { background: var(--vacant); }
.room-card.occupied { border-color: var(--occupied-border); background: var(--occupied-bg); }
.room-card.occupied::before { background: var(--occupied); }
.room-card.cleaning { border-color: var(--cleaning-border); background: var(--cleaning-bg); }
.room-card.cleaning::before { background: var(--cleaning); }
.room-card.maintenance { border-color: var(--maintenance-border); background: var(--maintenance-bg); }
.room-card.maintenance::before { background: var(--maintenance); }
.room-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.room-number { font-size: 1.3rem; font-weight: 800; }
.room-type { font-size: .75rem; color: var(--text-secondary); }
.room-floor { font-size: .7rem; color: var(--text-muted); }
.room-status-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 600; padding: .2rem .5rem; border-radius: 999px; margin-top: .5rem; }
.room-status-badge.vacant { background: var(--vacant); color: #fff; }
.room-status-badge.occupied { background: var(--occupied); color: #fff; }
.room-status-badge.cleaning { background: var(--cleaning); color: #fff; }
.room-status-badge.maintenance { background: var(--maintenance); color: #fff; }
.room-time { font-size: .65rem; color: var(--text-muted); margin-top: .3rem; }

/* ---- Badges & Status ---- */
.badge { display: inline-flex; align-items: center; padding: .25rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-vacant { background: var(--vacant-bg); color: var(--vacant); border: 1px solid var(--vacant-border); }
.badge-occupied { background: var(--occupied-bg); color: var(--occupied); border: 1px solid var(--occupied-border); }
.badge-cleaning { background: var(--cleaning-bg); color: var(--cleaning); border: 1px solid var(--cleaning-border); }
.badge-maintenance { background: var(--maintenance-bg); color: var(--maintenance); border: 1px solid var(--maintenance-border); }
.badge-pending { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-proses { background: #ede9fe; color: var(--primary-dark); border: 1px solid #ddd6fe; }
.badge-selesai { background: var(--vacant-bg); color: var(--vacant); border: 1px solid var(--vacant-border); }
.badge-admin { background: #ede9fe; color: var(--primary-dark); }
.badge-resepsionis { background: #ecfdf5; color: #065f46; }
.badge-housekeeping { background: #fff7ed; color: #c2410c; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: var(--transition); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--vacant); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--occupied); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--cleaning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: var(--body-bg); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: .4rem; border-radius: var(--radius-sm); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .4rem; color: var(--text-primary); }
.form-control { width: 100%; padding: .55rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: #fff; color: var(--text-primary); transition: var(--transition); }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-control.is-invalid { border-color: var(--occupied); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }
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='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { padding: .75rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; background: var(--body-bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; align-items: center; gap: .4rem; }

/* ---- Alerts ---- */
.alert { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 1rem; animation: fadeInDown .3s ease; }
.alert-icon { width: 18px; height: 18px; flex-shrink: 0; }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: .6; }
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--vacant-bg); color: #166534; border: 1px solid var(--vacant-border); }
.alert-danger { background: var(--occupied-bg); color: #991b1b; border: 1px solid var(--occupied-border); }
.alert-warning { background: var(--cleaning-bg); color: #92400e; border: 1px solid var(--cleaning-border); }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- Filters ---- */
.filters-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters-bar .form-control { min-width: 140px; max-width: 180px; }
.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-wrap .search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; }
.search-wrap .form-control { padding-left: 2.25rem; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: .3rem; margin-top: 1rem; }
.page-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--text-secondary); transition: var(--transition); }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fadeIn .2s ease; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 500px; box-shadow: var(--shadow-lg); animation: slideUp .25s ease; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.25rem; }
.modal-close:hover { color: var(--text-primary); }

/* ---- Chart Container ---- */
.chart-container { position: relative; height: 260px; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 1rem; opacity: .3; }
.empty-state p { font-size: .875rem; }

/* ---- Pulse animation for cleaning status ---- */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(245,158,11,.4); }
  70% { box-shadow: 0 0 0 8px rgba(245,158,11,0); }
  100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
}
.room-card.cleaning { animation: pulse-ring 2s infinite; }

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .4s ease; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .rooms-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .page-content { padding: 1rem; }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; display: none; }
  .sidebar-overlay.show { display: block; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .rooms-grid { grid-template-columns: 1fr 1fr; }
  .topbar-name { display: none; }
}

/* ---- QR Code Page ---- */
.qr-container { text-align: center; }
.qr-img { border: 8px solid #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); display: inline-block; }

/* ---- Loading Spinner ---- */
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-radius: var(--radius); background: #1e293b; color: #fff; font-size: .875rem; box-shadow: var(--shadow-lg); animation: slideUp .3s ease; min-width: 260px; max-width: 380px; }
.toast.toast-success { background: #166534; }
.toast.toast-danger { background: #991b1b; }
.toast.toast-warning { background: #92400e; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
