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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

:root {
    --bg-dark: #0f172a;
    --bg-sidebar: #090d16;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-red: #ef4444;
    --accent-red-hover: #dc2626;
    --accent-gold: #f59e0b;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;
    --accent-pink: #ec4899;
}

body {
    display: flex;
    height: 100vh;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    z-index: 10;
}

.sidebar .logo-container {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.sidebar .logo-container img {
    max-width: 180px;
    max-height: 150px;
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto 12px;
    transition: transform 0.3s ease;
}

.sidebar .logo-container img:hover {
    transform: scale(1.05);
}

.sidebar h2 {
    font-family: 'Playfair Display SC', serif;
    color: var(--accent-gold);
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.9;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar nav a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sidebar nav a:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-main);
    transform: translateX(4px);
}

.sidebar nav a.active {
    background: linear-gradient(135deg, var(--accent-red), #b91c1c);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-dark);
}

header {
    background-color: var(--bg-sidebar);
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

header p {
    font-size: 14px;
    color: var(--text-muted);

}

/* POS Layout */
.pos-layout {
    display: flex;
    flex: 1;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

.products-section {
    flex: 2;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.category-title {
    margin: 20px 0 12px 0;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border-color);
}

.category-title.salgado {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}

.category-title.doce {
    color: var(--accent-pink);
    border-color: var(--accent-pink);
}

.category-title.bebida {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 10px;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.product-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-gold);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.product-card:active {
    transform: scale(0.97);
}

.product-card h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 8px;
}

.product-card .price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent-green);
}

.product-card .code-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: var(--text-muted);
}

/* Cart Section */
.cart-section {
    flex: 1.1;
    min-width: 340px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.cart-section h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.buyer-info {
    margin-bottom: 16px;
}

.buyer-info label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.buyer-info input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: all 0.2s ease;
}

.buyer-info input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-cart {
    text-align: center;
    color: var(--text-muted);
    margin: auto;
    font-size: 15px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.cart-item-info h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.cart-item-info small {
    color: var(--accent-green);
    font-weight: 700;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    background: var(--bg-card-hover);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.qty-btn:hover {
    background: var(--accent-gold);
    color: black;
}

.remove-btn {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
}

.remove-btn:hover {
    background: var(--accent-red);
    color: white;
}

.cart-footer {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.total-row span:first-child {
    font-size: 15px;
    color: var(--text-muted);
    font-weight: 600;
}

.total-row span:last-child {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-gold);
}

.payment-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.payment-methods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.payment-methods label {
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid var(--border-color);
    text-align: center;
    transition: all 0.2s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.payment-methods label:hover {
    border-color: var(--accent-gold);
    background: var(--bg-card-hover);
}

.payment-methods input[type="radio"]:checked + label {
    border-color: var(--accent-red);
    background: linear-gradient(135deg, var(--accent-red), #b91c1c);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.payment-methods input {
    display: none;
}

.btn-checkout {
    background: linear-gradient(135deg, var(--accent-green), #16a34a);
    color: white;
    border: none;
    padding: 16px;
    width: 100%;
    font-size: 17px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-checkout:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

.btn-checkout:active {
    transform: translateY(0);
}

.btn-checkout:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* History Section */
.history-section {
    padding: 24px;
    background: var(--bg-sidebar);
    margin: 20px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    flex: 1;
    overflow-y: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th, .history-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.history-table th {
    background-color: var(--bg-card);
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table tbody tr:hover {
    background-color: var(--bg-card);
}

/* Queue Section */
.queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
}

.queue-card {
    background: var(--bg-sidebar);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--accent-gold);
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.queue-header h3 {
    color: var(--accent-gold);
    font-size: 20px;
    font-weight: 800;
}

.queue-header span {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 600;
}

.queue-items ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.queue-items li {
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    border-left: 3px solid var(--accent-gold);
}

.queue-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.queue-actions button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent-green), #16a34a);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.queue-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.4);
}

.queue-actions button.btn-cancel {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: var(--accent-red);
    box-shadow: none;
}

.queue-actions button.btn-cancel:hover {
    background: var(--accent-red);
    color: white;
}

/* Dashboard / Caixa */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    padding: 24px;
}

.dashboard-card {
    background-color: var(--bg-sidebar);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    text-align: center;
    border-top: 4px solid var(--border-color);
    transition: transform 0.2s ease;
}

.dashboard-card:hover {
    transform: translateY(-4px);
}

.dashboard-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-card .value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
}

.dashboard-card.primary {
    border-top-color: var(--accent-gold);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.1), var(--bg-sidebar));
    border: 1px solid var(--accent-gold);
}

.dashboard-card.primary h3 {
    color: var(--accent-gold);
}

.dashboard-card.primary .value {
    color: var(--accent-gold);
    font-size: 32px;
}

.dashboard-card.primary .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Custom Card Highlight */
.product-card.custom-card {
    background: linear-gradient(135deg, #312e81, #1e1b4b);
    border: 2px solid var(--accent-gold);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.product-card.custom-card:hover {
    border-color: #fde047;
    transform: translateY(-4px) scale(1.02);
}

/* Modal Overlay & Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-gold);
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.modal-subtitle {
    padding: 8px 24px;
    font-size: 14px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.required {
    color: var(--accent-red);
}

.counter-badge {
    font-size: 12px;
    font-weight: 700;
    background: var(--bg-card);
    color: var(--accent-gold);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.option-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.option-item:hover {
    border-color: var(--accent-gold);
    background: var(--bg-card-hover);
}

.option-item input[type="radio"]:checked + span,
.option-item input[type="checkbox"]:checked + span {
    color: var(--accent-gold);
    font-weight: 700;
}

.option-item input:disabled + span {
    opacity: 0.4;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--bg-sidebar);
}

.btn-cancel-modal {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-modal:hover {
    background: var(--bg-card-hover);
    color: white;
}

.btn-confirm-modal {
    background: linear-gradient(135deg, var(--accent-green), #16a34a);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    transition: all 0.2s;
}

.btn-confirm-modal:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.5);
}

/* =========================================
   RESPONSIVE DESIGN (MOBILE & TABLETS)
   ========================================= */

@media (max-width: 900px) {
    body {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        padding: 12px 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 15px rgba(0,0,0,0.4);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .sidebar .logo-container {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-bottom: 0;
        border-bottom: none;
        margin-bottom: 0;
    }

    .sidebar .logo-container img {
        max-width: 45px;
        max-height: 45px;
        margin: 0;
    }

    .sidebar h2 {
        display: none;
    }

    .sidebar nav {
        flex-direction: row;
        gap: 6px;
        margin-top: 0;
        overflow-x: auto;
    }

    .sidebar nav a {
        padding: 8px 12px;
        font-size: 13px;
        gap: 6px;
        white-space: nowrap;
    }

    .main-content {
        height: auto;
        overflow: visible;
    }

    header {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    header h1 {
        font-size: 18px;
    }

    header p {
        font-size: 12px;
    }

    .pos-layout {
        flex-direction: column;
        padding: 12px;
        gap: 16px;
        overflow: visible;
    }

    .products-section {
        overflow-y: visible;
        padding: 14px;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .product-card {
        padding: 12px;
        min-height: 90px;
    }

    .product-card h4 {
        font-size: 13px;
    }

    .product-card .price {
        font-size: 15px;
    }

    .cart-section {
        min-width: 100%;
        padding: 16px;
    }

    .payment-methods {
        grid-template-columns: 1fr 1fr;
    }

    .history-section {
        margin: 12px;
        padding: 12px;
        overflow-x: auto;
    }

    .history-table {
        font-size: 13px;
        min-width: 600px;
    }

    .history-table th, .history-table td {
        padding: 8px 10px;
    }

    .queue-grid {
        grid-template-columns: 1fr;
        padding: 10px 0;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        padding: 12px;
        gap: 12px;
    }

    .dashboard-card {
        padding: 16px;
    }

    .dashboard-card .value {
        font-size: 20px;
    }

    .dashboard-card.primary .value {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
