/* frontend-v3/css/pages/mobile.css */

:root {
    --bg-void: #06080c;
    --bg-surface-glass: rgba(13, 17, 30, 0.45);
    --bg-surface-solid: #0c101d;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-primary: #6366f1;
    --accent-primary-glow: rgba(99, 102, 241, 0.4);
    --accent-secondary: #06b6d4;
    --accent-secondary-glow: rgba(6, 182, 212, 0.4);
    --success: #10b981;
    --danger: #ef4444;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
}

/* Global resets for mobile.html to prevent white screen blocks */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    padding-bottom: 0px;
    background: var(--bg-void) !important;
    background-color: #06080c !important;
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y;
}

.glass-panel {
    background: var(--bg-surface-glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

/* Header styling */
.mobile-header {
    background: rgba(10, 14, 25, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 9000;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.menu-toggle-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-header-info h2 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.mobile-header-info p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.mobile-header-clock {
    text-align: right;
}

.mobile-header-clock span {
    font-family: monospace;
    font-weight: 700;
    color: var(--accent-secondary);
    font-size: 0.85rem;
}

.mobile-header-clock p {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* Main panels containers */
.mobile-panel {
    padding: 16px;
    padding-bottom: 95px !important;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-y;
}

/* Scrollable containers allow natural vertical touch panning */
.mobile-timeline-scroll,
.services-grid-wrapper,
.invoices-layout,
.rewards-layout,
.reports-layout,
.staff-layout,
.glass-panel {
    overscroll-behavior-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y;
}

/* Calendar Panel Specific: constrained to viewport so timeline scrolls smoothly */
#panel-calendar.mobile-panel {
    padding: 0 !important;
    padding-bottom: 65px !important;
    gap: 0 !important;
    height: calc(100vh - 55px);
    max-height: calc(100vh - 55px);
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
}

/* Dashboard items */
.mobile-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mobile-stat-card {
    padding: 14px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-glass);
    border: 1px solid var(--border-color);
}

.mobile-stat-card span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.mobile-stat-card h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 2px 0;
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: rgba(6, 8, 12, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 500;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-item.active {
    color: var(--accent-primary);
}

.nav-icon {
    font-size: 1.1rem;
}

.nav-label {
    font-size: 0.6rem;
    font-weight: 600;
}

/* Mobile Calendar Header */
.mobile-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(13, 17, 30, 0.85);
    border-bottom: 1px solid var(--border-color);
}

.mobile-calendar-header h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 700;
}

/* Week Selector: Touches both sides */
.mobile-week-selector {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    background: rgba(10, 14, 25, 0.7);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 0;
    border-radius: 0;
}

.mobile-weekday-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    border-radius: 0;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
}

.mobile-weekday-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.mobile-weekday-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    opacity: 0.8;
}

.mobile-day-value {
    font-size: 0.85rem;
    font-weight: 700;
}

.mobile-weekday-item.has-booking::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-secondary);
}

/* Mobile Scrollable Timeline: Touches sides and bottom navigation */
.mobile-timeline-scroll {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-x pan-y !important;
    transform: translateZ(0);
    will-change: scroll-position;
    background: #06080c;
    border: none;
    border-radius: 0;
    padding: 0; /* Zero padding to touch edges */
    position: relative;
}

.mobile-hour-row {
    display: grid;
    grid-template-columns: 55px 1fr;
    min-height: 120px;
    height: 120px;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.mobile-hour-label {
    font-family: monospace;
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding-top: 10px;
    position: sticky;
    left: 0;
    background: #090e18;
    z-index: 15;
    padding-left: 8px;
    border-right: 1px solid var(--border-color);
}

.mobile-hour-slot {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Absolute Overlay Canvas for Mobile */
.mobile-bookings-overlay-container {
    position: absolute;
    left: 55px; /* Touches slot boundary directly */
    top: 0;
    width: calc(100% - 55px);
    height: 1320px;
    min-height: 1320px;
    pointer-events: none;
    z-index: 100;
    transform: translateZ(0);
}

/* Absolute Positioned Mobile Booking Card: Hardware accelerated, crisp rendering */
.mobile-booking-card {
    position: absolute;
    background: #0f1526;
    border: 1px solid rgba(99, 102, 241, 0.45);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px;
    padding: 3px 6px;
    color: var(--text-primary);
    z-index: 200;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    overflow: hidden;
    pointer-events: auto !important;
    transform: translateZ(0);
    will-change: transform;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
/* Color Coding by Status for Mobile (High-performance solid tints) */
.mobile-booking-card.status-requested {
    background: #1a1710;
    border-color: rgba(245, 158, 11, 0.45);
    border-left-color: #f59e0b;
}
.mobile-booking-card.status-approved {
    background: #0f1526;
    border-color: rgba(99, 102, 241, 0.45);
    border-left-color: var(--accent-primary);
}
.mobile-booking-card.status-inprogress {
    background: #091a24;
    border-color: rgba(6, 182, 212, 0.45);
    border-left-color: var(--accent-secondary);
}
.mobile-booking-card.status-finished {
    background: #0a1f18;
    border-color: rgba(16, 185, 129, 0.45);
    border-left-color: var(--success);
}
.mobile-booking-card.status-denied {
    background: #200f13;
    border-color: rgba(239, 68, 68, 0.45);
    border-left-color: var(--danger);
}
.mobile-booking-card.status-private {
    background: #16181f;
    border-color: rgba(107, 114, 128, 0.45);
    border-left-color: var(--text-muted);
}

.mobile-booking-card:hover,
.mobile-booking-card.expanded {
    background: #182038 !important;
    border-color: var(--accent-primary) !important;
    z-index: 1000 !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    overflow: visible;
    min-width: 180px;
}

.mobile-card-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    width: 100%;
}

.mobile-card-client {
    font-weight: 700;
    font-size: 0.68rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.mobile-card-service {
    font-size: 0.58rem;
    line-height: 1.15;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.mobile-card-time {
    font-size: 0.55rem;
    font-family: monospace;
    color: var(--accent-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-booking-card:hover .mobile-card-client,
.mobile-booking-card:hover .mobile-card-service,
.mobile-booking-card:hover .mobile-card-time,
.mobile-booking-card.expanded .mobile-card-client,
.mobile-booking-card.expanded .mobile-card-service,
.mobile-booking-card.expanded .mobile-card-time {
    white-space: normal;
    overflow: visible;
}

/* Absolute Actions inside Mobile Card */
.mobile-card-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 20;
}

.mobile-booking-card:hover .mobile-card-actions,
.mobile-booking-card.expanded .mobile-card-actions {
    opacity: 1;
    pointer-events: auto;
}

.mobile-edit-btn {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #818cf8;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.mobile-edit-btn:hover,
.mobile-edit-btn:active {
    background: #6366f1;
    color: #ffffff;
}

.mobile-delete-btn {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.mobile-delete-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* SMS chat styles for Mobile */
.mobile-chat-container {
    background: rgba(13, 17, 30, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    height: 380px;
}

.mobile-chat-thread {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-chat-input-bar {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    background: rgba(10, 14, 25, 0.5);
}

.mobile-chat-input {
    flex-grow: 1;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.85rem;
}

/* POS checkout list for Mobile */
.mobile-pos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mobile-pos-card {
    background: var(--bg-surface-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mobile-pos-card:active {
    background: rgba(255,255,255,0.05);
}

.mobile-pos-card h4 {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.mobile-pos-card p {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 700;
}

/* Bottom checkout drawer */
.mobile-cart-drawer {
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(15px);
    border-top: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 65px;
    left: 0;
    right: 0;
    z-index: 450;
    box-shadow: 0 -8px 25px rgba(0,0,0,0.5);
}

.mobile-cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mobile-cart-header h4 {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.mobile-cart-rows {
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.mobile-cart-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Generic overlays */
.mobile-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 4, 8, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Message modal must always stack above client profile overlay */
#message-modal-overlay {
    z-index: 1300;
}

.mobile-modal-card {
    width: 100%;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* Form Styles */
.form-group-unified {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group-unified label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.form-group-unified input,
.form-group-unified select {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.85rem;
}
.form-group-unified select option {
    background-color: #0c101d;
    color: #fff;
}

.btn {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}

.btn-primary:active {
    background: rgba(99,102,241,0.85);
}

/* Modal Month Grid Day Cells */
.day-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    border: 1px solid transparent;
}

.day-cell:hover:not(.empty) {
    background: rgba(255,255,255,0.05);
}

.day-cell.today {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

.day-cell.selected {
    background: var(--accent-primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 10px var(--accent-primary-glow);
}

.day-cell.empty {
    cursor: default;
}

.day-indicator-dot {
    position: absolute;
    bottom: 2px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--accent-secondary);
}

.day-cell.selected .day-indicator-dot {
    background: #fff;
}

/* Mobile Slide-out Drawer (Hardware Accelerated) */
.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 4, 8, 0.85);
    z-index: 10000;
    display: flex;
    justify-content: flex-start;
    touch-action: manipulation;
}

.mobile-drawer-overlay.hidden {
    display: none !important;
}

.mobile-drawer {
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: #0a0e19 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    transform: translateZ(0);
    will-change: transform;
    animation: slide-in-left 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in-left {
    from { transform: translate3d(-100%, 0, 0); }
    to { transform: translate3d(0, 0, 0); }
}

/* Rotating phone warning and forced-landscape overlay preview */
@keyframes rotate-phone {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(0deg); }
    70% { transform: rotate(-90deg); }
    100% { transform: rotate(-90deg); }
}

.forced-landscape {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    width: 100vh !important;
    height: 100vw !important;
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: center !important;
    z-index: 3000 !important;
    background: #030508 !important;
}

#mob-tv-canvas-container {
    background-color: var(--bg-void);
}
