/* ============================================
   CLEAN POS STYLES - pos.css
   Duplicates removed, organized, and optimized
   ============================================ */

/* ============================================
   BASE STYLES
   ============================================ */

* {
    -webkit-tap-highlight-color: transparent;
}

.category-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
}

.item-btn:hover {
    transform: scale(1.05);
    transition: transform 0.2s;
}

.cart-item {
    cursor: pointer;
}

.cart-item:hover {
    background-color: #f3f4f6;
}

.num-pad-btn:active {
    background-color: #d1d5db;
}

.notification-item {
    animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   RESIZE HANDLES - DESKTOP
   ============================================ */

.resize-handle-vertical {
    width: 8px;
    cursor: col-resize;
    background: linear-gradient(90deg, transparent 0%, #cbd5e1 50%, transparent 100%);
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resize-handle-vertical:hover {
    background: linear-gradient(90deg, transparent 0%, #3b82f6 50%, transparent 100%);
}

.resize-handle-vertical::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: #94a3b8;
    border-radius: 2px;
}

.resize-handle-vertical:hover::before {
    background: #3b82f6;
}

.resize-handle-horizontal {
    height: 8px;
    cursor: row-resize;
    background: linear-gradient(180deg, transparent 0%, #cbd5e1 50%, transparent 100%);
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resize-handle-horizontal:hover {
    background: linear-gradient(180deg, transparent 0%, #3b82f6 50%, transparent 100%);
}

.resize-handle-horizontal::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 2px;
    background: #94a3b8;
    border-radius: 2px;
}

.resize-handle-horizontal:hover::before {
    background: #3b82f6;
}

/* Touch support for resize handles */
.resize-handle-vertical,
.resize-handle-horizontal,
#resize-cart-horizontal {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (hover: none) and (pointer: coarse) {
    .resize-handle-vertical {
        width: 16px;
    }

    .resize-handle-horizontal {
        height: 16px;
    }

    #resize-cart-horizontal {
        height: 16px;
    }
}

/* ============================================
   QUANTITY MODAL
   ============================================ */

#quantity-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

#quantity-modal .modal-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

#quantity-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

#quantity-modal .modal-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
}

#quantity-modal .close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quantity-modal .close-btn:hover {
    color: #1f2937;
}

#quantity-modal .item-info {
    background: #eff6ff;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #3b82f6;
}

#quantity-modal .item-name {
    font-weight: 600;
    font-size: 1.125rem;
    color: #1e40af;
}

#quantity-modal .item-price {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

#quantity-modal .keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

#quantity-modal .keypad button {
    padding: 1rem;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#quantity-modal .keypad button:hover {
    background: #e5e7eb;
    border-color: #3b82f6;
}

#quantity-modal .keypad button:active {
    transform: scale(0.95);
}

#quantity-modal .actions {
    display: flex;
    gap: 0.75rem;
}

#quantity-modal .actions button {
    flex: 1;
    padding: 0.875rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

#quantity-modal .cancel-btn {
    background: white;
    border: 2px solid #d1d5db;
    color: #6b7280;
}

#quantity-modal .cancel-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

#quantity-modal .apply-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    color: white;
}

#quantity-modal .apply-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

#quantity-modal .discount-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    color: white;
}

#quantity-modal .discount-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Quantity display - half size */
#qty-display {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
}

/* ============================================
   PRODUCT GRID - RESPONSIVE
   ============================================ */

/* Desktop - 5 cards per row */
@media (min-width: 1025px) {
    #product-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

/* Tablet Portrait - 4 cards per row */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    #product-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Tablet Landscape - 5 cards per row */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    #product-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

/* Phone Portrait - 3 cards per row */
@media (max-width: 767px) and (orientation: portrait) {
    #product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Phone Landscape - 4 cards per row */
@media (max-width: 767px) and (orientation: landscape) {
    #product-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ============================================
   LAYOUT IMPROVEMENTS
   ============================================ */

/* Right panel flexbox for held orders at bottom */
#right-panel {
    display: flex;
    flex-direction: column;
}

/* Push held orders section to bottom */
#right-panel > .p-3.bg-gradient-to-r {
    margin-top: auto !important;
}

/* Hide old quantity controls section (moved to modal) */
.p-3.bg-white.border-t.border-gray-300:has(#keypad-content) {
    display: none !important;
}

/* Let cart items fill available space */
#cart-items {
    flex: 1 1 auto !important;
    overflow-y: auto;
}

/* ============================================
   DESKTOP VIEW (> 1024px)
   ============================================ */

@media (min-width: 1025px) {
    #resize-cart-horizontal {
        display: none !important;
    }

    #resize-main,
    #resize-cart-summary {
        display: block !important;
    }
}

/* ============================================
   TABLET VIEW (768px - 1024px)
   ============================================ */

@media (max-width: 1024px) and (min-width: 768px) {
    header h1 {
        font-size: 1.25rem;
    }

    header .flex.items-center.space-x-4 {
        gap: 0.5rem;
    }

    header button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    #edit-mode {
        display: none !important;
    }

    #main-content {
        flex-direction: column !important;
    }

    #left-panel {
        width: 100% !important;
        height: 50vh;
        flex: none !important;
    }

    .item-btn {
        padding: 0.75rem;
    }

    .item-btn .font-semibold {
        font-size: 0.875rem;
    }

    #right-panel {
        width: 100% !important;
        height: 50vh;
        flex: none !important;
        border-left: none;
        border-top: 2px solid #d1d5db;
    }

    #resize-main {
        display: none !important;
    }

    #resize-cart-horizontal {
        display: block !important;
        height: 12px;
        width: 100%;
        cursor: row-resize;
        background: linear-gradient(180deg, transparent 0%, #3b82f6 50%, transparent 100%);
        position: relative;
        touch-action: none;
    }

    #resize-cart-horizontal::before {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 60px;
        height: 4px;
        background: #3b82f6;
        border-radius: 2px;
    }

    #cart-items {
        max-height: 200px;
        overflow-y: auto;
    }

    #right-panel > div:first-child {
        padding: 0.75rem;
        margin: 0.75rem;
    }

    #pos-table-number {
        font-size: 1rem;
    }

    #change-table-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    #right-panel > .action-buttons-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #view-held-orders {
        grid-column: span 2;
    }

    #payment-modal > div,
    #user-select-modal > div,
    #pin-modal > div,
    #sales-report-modal > div,
    #quantity-modal .modal-content {
        width: 90vw !important;
        max-width: none;
        max-height: 85vh;
    }

    button {
        min-height: 44px;
    }

    #quantity-modal .keypad button {
        padding: 1.25rem;
        font-size: 1.5rem;
    }
}

/* ============================================
   PHONE VIEW (< 768px)
   ============================================ */

@media (max-width: 767px) {
    header {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1rem;
    }

    header .flex.items-center.space-x-4 {
        gap: 0.25rem;
        flex-wrap: wrap;
    }

    header button {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    #sales-report,
    #edit-mode,
    #notifications-btn {
        display: none !important;
    }

    #current-user,
    #current-role {
        font-size: 0.75rem;
    }

    #main-content {
        flex-direction: column !important;
    }

    #left-panel {
        width: 100% !important;
        height: 40vh;
        flex: none !important;
    }

    #category-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .category-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .item-btn {
        padding: 0.5rem;
    }

    .item-btn .w-16.h-16 {
        width: 3rem;
        height: 3rem;
    }

    .item-btn .font-semibold {
        font-size: 0.75rem;
    }

    .item-btn .text-blue-600 {
        font-size: 0.875rem;
    }

    #right-panel {
        width: 100% !important;
        height: 60vh;
        flex: none !important;
        border-left: none;
        border-top: 2px solid #d1d5db;
    }

    #resize-main,
    #resize-cart-summary {
        display: none !important;
    }

    #right-panel > div:first-child {
        padding: 0.5rem;
        margin: 0.5rem;
    }

    #pos-table-number {
        font-size: 0.875rem;
    }

    #change-table-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .cart-header {
        padding: 0.75rem;
    }

    .cart-header h2 {
        font-size: 1rem;
    }

    .cart-header span {
        font-size: 0.75rem;
    }

    #cart-items {
        padding: 0.5rem;
        max-height: 150px;
    }

    .cart-item {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .cart-item .font-semibold {
        font-size: 0.875rem;
    }

    .cart-item .qty-btn {
        width: 1.75rem;
        height: 1.75rem;
    }

    #order-summary {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    #order-summary .text-lg {
        font-size: 1rem;
    }

    .action-buttons-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    #clear-cart,
    #hold-order,
    #checkout,
    #view-open-tabs {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    #view-held-orders {
        grid-column: span 2;
        padding: 0.75rem;
    }

    #payment-modal,
    #user-select-modal,
    #pin-modal,
    #sales-report-modal,
    #quantity-modal {
        padding: 0.5rem;
    }

    #payment-modal > div,
    #user-select-modal > div,
    #pin-modal > div,
    #sales-report-modal > div,
    #quantity-modal .modal-content {
        width: 95vw !important;
        max-width: none;
        max-height: 90vh;
        padding: 1rem;
    }

    button {
        min-height: 48px;
    }

    #notifications-panel,
    #held-orders-panel {
        width: 100vw !important;
    }

    #quantity-modal .keypad button {
        padding: 1rem;
        font-size: 1.25rem;
    }
}

/* Category Filter Buttons - Match Products Page Style */
#category-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.category-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    font-size: 0.875rem;
}

.category-btn:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

.category-btn-empty {
    opacity: 0.6;
    font-style: italic;
}

.category-btn-empty:hover {
    opacity: 1;
}

/* Product count badge */
.filter-count {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-left: 0.25rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
}

.category-btn.active .filter-count {
    opacity: 1;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
}

.filter-count-empty {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-left: 0.25rem;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #category-nav {
        padding: 0.5rem 0;
    }

    .category-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    .filter-count,
    .filter-count-empty {
        font-size: 0.7rem;
    }
}

/* Scrollbar styling for category nav */
#category-nav::-webkit-scrollbar {
    height: 6px;
}

#category-nav::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#category-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#category-nav::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}