/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* CSS Variables for consistent theming */
:root {
    --primary: #6366f1;
    --primary-hover: #5855eb;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-secondary: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
}

.hidden {
    display: none !important;
}

/* Mobile-first base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 2;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--background) 0%, #e2e8f0 100%);
    color: var(--text-primary);
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
}

.bg-white {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

img.logo {
    display: block;
    margin: 0 auto 2rem auto;
    height: 4rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

input,
button {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input {
    background: var(--surface);
    color: var(--text-primary);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

button {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

button:active {
    transform: translateY(0);
}

button.bg-green-500 {
    background: linear-gradient(135deg, var(--success), #059669);
}

button.bg-red-500 {
    background: linear-gradient(135deg, var(--danger), #dc2626);
}

button.bg-yellow-500 {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: white;
}

button.bg-black {
    background: linear-gradient(135deg, var(--dark), #111827);
}

button.bg-gray-500 {
    background: linear-gradient(135deg, #caccca, #d4d4d4);
    color: #808a98;
}

button.cancelDiscount {
    width: 50%!important;
    border-radius: 10px!important;
    margin-top: 10px!important;
}

button.editItem {
    width: 50%!important;
    border-radius: 10px!important;
    margin-top: 10px!important;
}

button.removeItem {
    width: 50%!important;
    margin-top: 10px!important;
    border-radius: 10px!important;
}

button#addNewSection {
    margin-top: 10px;
}

button.editSection    {
display: none!important;
}

button.novoItem {
    width: 50%!important;
    margin-top: 10px!important;
    border-radius: 10px!important;
}

button.cancelar {
    width: 50%!important;
    margin-top: 10px!important;
    border-radius: 10px!important;
}

button.addDiscount {
    width: 50% !important;
    margin-top: 10px !important;
    border-radius: 10px !important;
   font-size: x-small !important;
}

button.editBtn {
    width: 50%!important;
    margin-top: 10px!important;
    border-radius: 10px!important;
}

button.deleteBtn {
    width: 50%!important;
    margin-top: 10px!important;
    border-radius: 10px!important;
}

button.aplicar {
     width: 50%!important;
    margin-top: 10px!important;
    border-radius: 10px!important;
}

button.addItem {
    width: 3rem!important;
    height: 3rem!important;
    margin-top: 20px!important;
}

.section {
    background: var(--surface-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    position: relative;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.section .flex {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    justify-content: space-between;
}

.section .sectionTitle {
    background: none;
    border: none;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    flex-grow: 1;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.section .sectionTitle:focus {
    outline: none;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.section button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem;
    min-width: 2rem;
}

.savedItems p {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.itemForm,
.discountForm {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.itemForm label,
.discountForm label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

#preview {
    padding: 1rem; /* p-4 */
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin-top: 1.5rem; /* mt-6 */
    border: 1px solid var(--border); /* border */
}

#preview h2 {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
    margin-bottom: 1rem; /* mb-4 */
}

#previewContent {
    margin-bottom: 1rem; /* mb-4 */
}

#preview button {
    padding: 0.5rem; /* p-2 */
    background: linear-gradient(135deg, #6b7280, #4b5563); /* bg-gray-500 */
    color: white;
    border-radius: var(--radius);
}

#preview table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border); /* border border-gray-300 */
    margin-bottom: 1rem; /* mb-4 */
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

#preview th,
#preview td {
    padding: 0.5rem; /* p-2 */
    border: 1px solid var(--border); /* border border-gray-300 */
}

#preview th {
    background: var(--surface-secondary); /* bg-gray-100 */
    text-align: left;
    font-weight: 600;
}

#preview th:nth-child(2),
#preview th:nth-child(3),
#preview th:nth-child(5) {
    text-align: center;
}

#preview th:last-child,
#preview td:last-child {
    text-align: right;
}

#preview .font-bold {
    font-weight: 700;
}

#summary {
    margin-top: 1.5rem; /* mt-6 */
}

#summary h2 {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
}

#summary #sectionTotals,
#summary #totalGeral {
    padding: 0.5rem; /* p-2 */
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

#notesSection h2 {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
}

#notesList p {
    background: var(--surface-secondary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

#notesList button {
    margin-left: 1rem;
}

.welcome {
    white-space: pre-line;
    line-height: 1.5;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus states for accessibility */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus,
input:focus {
    outline: none;
}

/* Tablet and Desktop Breakpoints */
@media (min-width: 640px) {
    .container {
        max-width: 640px;
        padding: 1.5rem;
    }
    
    .bg-white {
        padding: 2rem;
    }
    
    form {
        gap: 1.5rem;
    }
}

@media (min-width: 768px) {
    body {
        font-size: 15px;
    }
    
    .container {
        max-width: 768px;
    }
    
    h1 {
        font-size: 2.25rem;
        margin-bottom: 2.5rem;
    }
    
    img.logo {
        height: 5rem;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
        padding: 2rem;
    }
    
    .bg-white {
        padding: 3rem;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    img.logo {
        height: 6rem;
    }
    
    .section .sectionTitle {
        font-size: 1.25rem;
    }
    
    .section {
        padding: 2rem;
    }
    
    #preview {
        padding: 2rem;
    }
    
    #preview th,
    #preview td {
        padding: 1.25rem 1rem;
    }
}

/* Logo inversion for light mode */
@media (prefers-color-scheme: light) {
    img.logo {
        filter: invert(1);
    }
}

/* For print: always invert logo since printing on white paper */
@media print {
    img.logo {
        filter: invert(1) !important;
    }
    .bg-white {
        background: white !important;
    }
    #preview {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --surface-secondary: #334155;
        --border: #475569;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
    }
    
    body {
        background: linear-gradient(135deg, var(--background) 0%, #1e293b 100%);
    }
    
    img.logo {
        filter: invert(0); /* Keep white in dark mode */
    }
}

/* Animation for loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
