/**
 * Warehouse Label Manager - Styles
 * Design industrial/dark otimizado para mobile
 */

@import url('https://fonts.googleapis.com/css2?family=Chivo:wght@400;700;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

/* ============================================
   CSS Variables
============================================ */
:root {
    --bg-primary: #f4f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f1f3f5;

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;

    --accent-primary: #f59e0b;
    --accent-hover: #d97706;
    --accent-light: rgba(245, 158, 11, 0.15);

    --border-color: #d4d4d8;
    --border-light: rgba(0, 0, 0, 0.08);

    --success: #16a34a;
    --error: #dc2626;
    --warning: #d97706;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.12);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Chivo', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ============================================
   Reset & Base
============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
============================================ */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

.text-huge {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.text-large {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
}

.text-mono {
    font-family: var(--font-mono);
}

.text-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--accent-primary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

/* ============================================
   Layout
============================================ */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    background: #ffffff;
    min-height: 100vh;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.page-header-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.section {
    margin-bottom: 1.5rem;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

/* ============================================
   Components - Buttons
============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.3);
}

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

.btn-primary:active {
    box-shadow: none;
    transform: translateY(2px);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-input);
    border-color: var(--accent-primary);
}

.btn-secondary.active {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background-color: var(--accent-light);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
}

.btn-lg {
    height: 56px;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Components - Inputs
============================================ */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input {
    width: 100%;
    height: 56px;
    padding: 0 1rem;
    font-family: var(--font-sans);
    font-size: 1.125rem;
    color: var(--text-primary);
    background-color: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease;
    -webkit-appearance: none;
}

.input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.input::placeholder {
    color: var(--text-muted);
}

.input-code {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.5em;
}

.input-qty {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
}

/* Remove spinner from number inputs */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.input[type="number"] {
    -moz-appearance: textfield;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-box .input {
    flex: 1;
}

/* ============================================
   Components - Cards
============================================ */
.card {
    background-color: #f3f3f3;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 1rem;
    transition: border-color 0.15s ease;
    margin-bottom: 10px;
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    border-color: rgba(245, 158, 11, 0.5);
}

.card-interactive:active {
    background-color: var(--accent-light);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-qty {
    text-align: right;
}

.card-qty-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.card-qty-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
}

/* ============================================
   Components - Tags/Badges
============================================ */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: var(--bg-input);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.tag svg {
    width: 12px;
    height: 12px;
}

/* ============================================
   Components - Modal/Dialog
============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
}

.modal-footer .btn {
    flex: 1;
}

/* ============================================
   Components - Toast/Notifications
============================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: calc(100% - 2rem);
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-bottom: 0.5rem;
    animation: slideDown 0.3s ease;
}

.toast-success {
    border-color: var(--success);
}

.toast-error {
    border-color: var(--error);
}

.toast-icon {
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   Login Page
============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-image: url('https://images.pexels.com/photos/12488654/pexels-photo-12488654.jpeg');
    background-size: cover;
    background-position: center;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.85);
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: #ffffff;
    backdrop-filter: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background-color: var(--accent-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo-icon svg {
    width: 32px;
    height: 32px;
    color: var(--accent-primary);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Label Preview
============================================ */
.label-preview-container {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.label-preview {
    background-color: #ffffff;
    color: #000000;
    font-family: Arial, sans-serif;
    padding: 8px;
    border-radius: 4px;
    aspect-ratio: 50 / 30;
    max-width: 300px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.label-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.label-logo {
    height: 16px;
    width: auto;
}

.label-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.label-ref {
    font-size: 18px;
    font-weight: 900;
}

.label-qty-box {
    text-align: right;
}

.label-qty-type {
    font-size: 6px;
    text-transform: uppercase;
    color: #666;
}

.label-qty-value {
    font-size: 18px;
    font-weight: 900;
}

.label-barcode {
    text-align: center;
    margin: 4px 0;
}

.label-barcode svg {
    max-width: 100%;
    height: 30px;
}

.label-footer {
    border-top: 1px solid #ddd;
    padding-top: 4px;
    font-size: 7px;
    color: #333;
}

.label-desc {
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.label-info {
    display: flex;
    justify-content: space-between;
    color: #666;
}

/* ============================================
   History/Logs
============================================ */
.log-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.log-change {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.log-old {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    color: var(--error);
}

.log-arrow {
    color: var(--text-muted);
}

.log-new {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    color: var(--success);
}

.log-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* ============================================
   Empty States
============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--text-muted);
    opacity: 0.3;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============================================
   Loading
============================================ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-input);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Quantity Controls
============================================ */
.qty-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.qty-controls .input {
    flex: 1;
}

.qty-btn {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

/* ============================================
   Type Selection
============================================ */
.type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.type-btn {
    height: 64px;
    flex-direction: column;
    gap: 0.25rem;
}

.type-btn svg {
    width: 24px;
    height: 24px;
}

.type-btn span {
    font-size: 0.75rem;
}

/* ============================================
   Utility Classes
============================================ */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================
   Responsive
============================================ */
/*@media (min-width: 640px) {
    .container {
        padding: 1.5rem;
    }
}*/

/* Safe area for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
