/* =============================================
   Clark POS Admin - Base Styles
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; color: #e0e0e0; background: #121212; }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #121212; }

.login-wrap { background: #1e1e1e; border: 1px solid #333; border-radius: 8px; padding: 40px 36px; width: 360px; }

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-title { font-size: 24px; font-weight: 700; color: #fff; letter-spacing: 2px; }
.login-logo-sub   { font-size: 12px; color: #888; margin-top: 4px; }

.login-alert      { background: #3a1a1a; border: 1px solid #c0392b; color: #e74c3c; border-radius: 4px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.login-alert-info { background: #1a2a1a; border-color: #2ecc71; color: #2ecc71; }

.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-size: 12px; color: #aaa; margin-bottom: 5px; }

.form-input { width: 100%; background: #2a2a2a; border: 1px solid #444; border-radius: 4px; color: #e0e0e0; padding: 10px 12px; font-size: 14px; outline: none; }
.form-input:focus { border-color: #4e73df; }

.login-btn { width: 100%; background: #4e73df; color: #fff; border: none; border-radius: 4px; padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.login-btn:hover { background: #375ab5; }

/* ---- Layout ---- */
.admin-body { display: flex; height: 100vh; overflow: hidden; }

.sidebar { width: 220px; height: 100vh; background: #1a1a2e; display: flex; flex-direction: column; transition: width 0.2s; flex-shrink: 0; }
.sidebar.collapsed { width: 0; overflow: hidden; }

.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid #2a2a4a; }
.sidebar-logo    { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.sidebar-sub     { font-size: 11px; color: #7a7aaa; margin-top: 2px; }

.sidebar-nav     { flex: 1; padding: 10px 0; }
.nav-item        { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #aaa; text-decoration: none; font-size: 14px; transition: background 0.15s; }
.nav-item:hover  { background: #2a2a4a; color: #fff; }
.nav-item.active { background: #4e73df; color: #fff; }
.nav-icon        { font-size: 8px; }

.sidebar-footer  { padding: 16px 20px; border-top: 1px solid #2a2a4a; font-size: 12px; color: #888; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logout-btn      { background: #333; border: 1px solid #555; color: #ccc; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.logout-btn:hover { background: #c0392b; border-color: #c0392b; color: #fff; }

.main-wrapper    { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar          { height: 52px; background: #1e1e1e; border-bottom: 1px solid #333; display: flex; align-items: center; padding: 0 20px; gap: 14px; flex-shrink: 0; }
.sidebar-toggle  { background: none; border: none; color: #aaa; font-size: 18px; cursor: pointer; padding: 4px 8px; }
.sidebar-toggle:hover { color: #fff; }

.sidebar-backdrop { display: none; }

/* 태블릿 이하: 사이드바는 오버레이 (기본 닫힘) */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1001;
        transform: translateX(0);
        transition: transform 0.2s;
    }
    .sidebar.collapsed { width: 220px; overflow: visible; transform: translateX(-100%); }

    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; }
}
.topbar-title    { font-size: 16px; font-weight: 600; color: #e0e0e0; }

.content-area    { flex: 1; padding: 24px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }

/* ---- Page Header ---- */
.page-header   { margin-bottom: 20px; }
.page-title    { font-size: 20px; font-weight: 600; color: #fff; }

/* ---- Stats Grid ---- */
.stats-grid    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 0; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card     { background: #1e1e1e; border: 1px solid #333; border-radius: 8px; padding: 20px; text-align: center; }
.stat-label    { font-size: 12px; color: #888; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value    { font-size: 26px; font-weight: 700; color: #4e73df; }

/* ---- Cards ---- */
.card          { background: #1e1e1e; border: 1px solid #333; border-radius: 8px; overflow: hidden; }
.card-header   { padding: 14px 18px; border-bottom: 1px solid #333; font-size: 14px; font-weight: 600; color: #ccc; display: flex; align-items: center; gap: 8px; }
.card-body     { padding: 16px 18px; }
.card-body.p-0 { padding: 0; }

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }

/* ---- Table ---- */
.admin-table   { width: 100%; border-collapse: collapse; }
.admin-table th,
.admin-table td { padding: 10px 14px; border-bottom: 1px solid #2a2a2a; font-size: 13px; }
.admin-table th { background: #252525; color: #aaa; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; text-align: left; }
.admin-table tbody tr:hover { background: #252530; }
.admin-table .no-data { text-align: center; color: #666; padding: 32px; }

.expand-col    { width: 30px; text-align: center; color: #888; }

tfoot .foot-total td { background: #1a1a2e; font-weight: 700; color: #fff; padding: 12px 14px; }

/* ---- Dashboard ---- */
.dashboard-content  { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.dashboard-top-row  { display: flex; flex-wrap: wrap; gap: 16px; }
.dashboard-type-card { flex: 2 1 480px; }
.dashboard-total-card { flex: 1 1 240px; }
.dashboard-month-card { flex: 1 1 200px; }
.recent-orders-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chart-header  { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.month-select  { background: #2a2a2a; border: 1px solid #444; border-radius: 4px; color: #e0e0e0; padding: 6px 10px; font-size: 13px; outline: none; }
.month-select:focus { border-color: #4e73df; }

@media (max-width: 700px) {
    .dashboard-type-card,
    .dashboard-total-card,
    .dashboard-month-card { flex-basis: 100%; }

    .dashboard-content { height: auto; overflow: visible; }
    .recent-orders-card { min-height: 280px; }
}

/* ---- Search Bar ---- */
.search-bar    { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-input-sm { background: #2a2a2a; border: 1px solid #444; border-radius: 4px; color: #e0e0e0; padding: 7px 10px; font-size: 13px; outline: none; }
.form-input-sm:focus { border-color: #4e73df; }
.sep           { color: #666; }
.result-count  { font-size: 13px; color: #888; }

.btn-primary   { background: #4e73df; color: #fff; border: none; border-radius: 4px; padding: 7px 18px; font-size: 13px; cursor: pointer; }
.btn-primary:hover { background: #375ab5; }

/* ---- Badges ---- */
.badge         { display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.badge-dine    { background: #1a3a2a; color: #2ecc71; }
.badge-takeout { background: #1a2a3a; color: #3498db; }
.badge-delivery{ background: #2a2a1a; color: #f39c12; }
.badge-app     { background: #2a1a3a; color: #9b59b6; }
.badge-other   { background: #2a2a2a; color: #aaa; }

/* ---- Profile Link ---- */
.profile-link { color: #aaa; cursor: pointer; text-decoration: none; }
.profile-link:hover { color: #fff; text-decoration: underline; }

/* ---- Modal ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: #1e1e1e; border: 1px solid #444; border-radius: 8px; width: 360px; max-width: 95vw; padding: 0; overflow: hidden; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid #333; font-size: 15px; font-weight: 600; color: #fff; display: flex; align-items: center; justify-content: space-between; }
.modal-close { background: none; border: none; color: #888; font-size: 18px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-label { display: block; font-size: 12px; color: #aaa; margin-bottom: 5px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #333; display: flex; justify-content: flex-end; gap: 8px; }
.btn-secondary { background: #333; border: 1px solid #555; color: #ccc; border-radius: 4px; padding: 7px 18px; font-size: 13px; cursor: pointer; }
.btn-secondary:hover { background: #444; color: #fff; }
.modal-alert { font-size: 12px; padding: 8px 12px; border-radius: 4px; }
.modal-alert-error { background: #3a1a1a; border: 1px solid #c0392b; color: #e74c3c; }
.modal-alert-success { background: #1a2a1a; border: 1px solid #2ecc71; color: #2ecc71; }

/* ---- Sticky 헤더 표 (목록 페이지: 헤더/본문이 같은 스크롤 영역 → 가로 스크롤 시 컬럼 정렬 유지) ---- */
.table-scroll  { min-height: 0; }
.sticky-head thead th { position: sticky; top: 0; z-index: 1; }

/* ---- Responsive: 태블릿 이하 ---- */
@media (max-width: 1024px) {
    .content-area  { padding: 16px; }
    .admin-table th,
    .admin-table td { padding: 8px 10px; }
}

/* ---- Responsive: 모바일 ---- */
@media (max-width: 768px) {
    .topbar        { padding: 0 10px; gap: 8px; }
    .topbar-title  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .content-area  { padding: 10px; }

    /* 고정 높이(화면 꽉 채움) 레이아웃 해제 → 페이지 전체 세로 스크롤 */
    .content-area > div { height: auto !important; }
    .content-area .card[style*="flex: 1"],
    .content-area .card[style*="flex:1"] { flex: none !important; }
    .content-area .card-body.p-0 { overflow-x: auto !important; overflow-y: visible !important; }
    .table-scroll  { overflow-x: auto !important; overflow-y: visible !important; flex: none !important; }

    .page-header   { margin-bottom: 12px; }
    .page-title    { font-size: 17px; }
    .mt-20         { margin-top: 12px; }
    .card-header   { padding: 10px 12px; flex-wrap: wrap; }
    .card-body     { padding: 12px; }
    .card-body.p-0 { padding: 0; }

    /* 표: 컬럼을 줄이지 않고 가로 스크롤 */
    .admin-table   { min-width: 640px; }
    .admin-table th,
    .admin-table td { padding: 7px 8px; font-size: 12px; white-space: nowrap; }
    .admin-table th { font-size: 10px; }

    /* 검색 조건: 줄바꿈하며 가득 채움 (인라인 고정 폭 무시) */
    .search-bar    { gap: 6px; }
    .search-bar .form-input-sm { flex: 1 1 130px; width: auto !important; min-width: 0; }
    .search-bar select.form-input-sm { flex-basis: 100%; }
    .search-bar input[type="date"].form-input-sm { flex: 1 1 120px; }
    .search-bar .sep { flex: 0 0 auto; }
    .search-bar .btn-primary,
    .search-bar .btn-secondary { flex: 1 1 auto; padding: 8px 12px; }
    .search-bar .result-count { flex-basis: 100%; }

    .stats-grid    { gap: 10px; }
    .stat-card     { padding: 14px 10px; }
    .stat-value    { font-size: 20px; }

    .modal-box     { width: 100% !important; }
    .modal-footer  { flex-wrap: wrap; }

    /* 일마감 상세 팝업 */
    .sttl-wrap     { top: 8px !important; bottom: 8px !important; width: calc(100% - 16px) !important; }
    .sttl-body     { padding: 10px !important; overflow-x: auto; }
    .sttl-footer   { flex-wrap: wrap; justify-content: stretch !important; }
    .sttl-footer button { flex: 1 1 auto; padding: 9px 12px !important; }

    .login-wrap    { width: calc(100% - 24px); max-width: 360px; padding: 32px 22px; }
}

@media (max-width: 480px) {
    .stats-grid    { grid-template-columns: 1fr 1fr; }
    .stat-value    { font-size: 18px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
