/* ===================================
   UnoASAT - Premium Design System v2
   =================================== */

/* CSS Variables */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --bg-card: rgba(31, 41, 55, 0.6);
    --bg-card-hover: rgba(55, 65, 81, 0.7);

    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --border-color: rgba(75, 85, 99, 0.4);
    --border-focus: rgba(59, 130, 246, 0.5);

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.3);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Screens */
.screen {
    display: none !important;
}

.screen.active {
    display: block !important;
}

/* ===================================
   Login Screen
   =================================== */
#login-screen.active {
    display: flex !important;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo {
    justify-content: center;
    margin-bottom: 1.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-error {
    color: var(--accent-danger);
    font-size: 0.875rem;
    text-align: center;
    margin-bottom: 1rem;
    min-height: 1.25rem;
}

/* ===================================
   Header
   =================================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user span {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* ===================================
   Main Content
   =================================== */
.main-content {
    padding: 2rem 0 4rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    background: none;
    border: none;
    font-size: 0.9375rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: color var(--transition-fast);
}

.back-button:hover {
    color: var(--text-primary);
}

.back-button svg {
    width: 20px;
    height: 20px;
}

/* ===================================
   Cards Grid
   =================================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
}

.card:hover:not(.card--disabled) {
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.card-icon svg {
    width: 28px;
    height: 28px;
}

.card-icon--quimicos {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
    color: var(--accent-primary);
}

.card-icon--mantenimiento {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
    color: var(--accent-success);
}

.card-icon--averia {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
    color: var(--accent-danger);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1rem;
}

.card-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-primary);
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9375rem;
}

.card-button svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

.card:hover .card-button svg {
    transform: translateX(4px);
}

.card-button--urgent {
    color: var(--accent-danger);
}

.card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* ===================================
   Forms
   =================================== */
.form-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-group .optional {
    font-weight: 400;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group .form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    margin-top: 2rem;
}

/* Month Grid */
.month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.month-btn {
    padding: 0.75rem 0.5rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.month-btn:hover:not(:disabled) {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.month-btn.selected {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: white;
}

.month-btn--disabled {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.month-btn--disabled:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

/* File Upload */
.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-align: center;
    transition: all var(--transition-fast);
}

.file-upload-content svg {
    width: 32px;
    height: 32px;
}

.file-upload-content small {
    font-size: 0.75rem;
}

.file-upload:hover .file-upload-content {
    border-color: var(--accent-primary);
    color: var(--text-secondary);
}

.file-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.file-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.file-preview-item img,
.file-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-item .remove-file {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================
   Buttons
   =================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: 0.9375rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn--primary {
    background: var(--gradient-primary);
    color: white;
}

.btn--primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn--secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn--secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn--small {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn--full {
    width: 100%;
}

.btn--urgent {
    background: var(--gradient-danger);
}

.btn .btn-loader {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loader {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================================
   Químicos - Catalog
   =================================== */
.quimicos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.cart-button {
    position: relative;
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.cart-button:hover {
    background: var(--bg-card-hover);
}

.cart-button svg {
    width: 24px;
    height: 24px;
}

.cart-button span {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 22px;
    height: 22px;
    background: var(--accent-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.brand-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.brand-tab {
    flex: 1;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.brand-tab:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.brand-tab.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.brand-tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.brand-tab small {
    font-size: 0.6875rem;
    font-weight: 400;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    transition: all var(--transition-fast);
}

.product-card:hover {
    background: var(--bg-card-hover);
}

.product-image {
    width: 80px;
    height: 80px;
    background: transparent;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.product-code {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.product-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.product-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.qty-control {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.qty-control button {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-control button:hover {
    background: var(--bg-card-hover);
}

.qty-control input {
    width: 40px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.add-to-cart {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-to-cart:hover {
    background: #2563eb;
}

.add-to-cart.added {
    background: var(--accent-success);
}

/* ===================================
   Cart Sidebar
   =================================== */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-base);
}

.cart-sidebar.open {
    transform: translateX(0);
}

.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.cart-overlay.open {
    opacity: 1;
    visibility: visible;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.cart-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.cart-close {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.cart-close svg {
    width: 20px;
    height: 20px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.cart-item-image {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cart-item-image img {
    max-width: 100%;
    max-height: 100%;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.cart-item-remove {
    padding: 0.25rem 0.5rem;
    background: none;
    border: none;
    color: var(--accent-danger);
    font-size: 0.75rem;
    cursor: pointer;
}

.cart-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ===================================
   Toast
   =================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-success);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 1100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.toast-icon {
    width: 40px;
    height: 40px;
    background: rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-success);
}

.toast-icon svg {
    width: 20px;
    height: 20px;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===================================
   Contact Section
   =================================== */
.contact-section {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    text-align: center;
}

.contact-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.contact-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.contact-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.contact-btn:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.contact-btn svg {
    width: 20px;
    height: 20px;
}

.contact-btn--whatsapp {
    background: #25D366;
    border-color: #25D366;
    color: white;
}

.contact-btn--whatsapp:hover {
    background: #22c55e;
    box-shadow: 0 0 20px rgba(37, 211, 102, 0.3);
}

/* ===================================
   App Footer
   =================================== */
.app-footer {
    margin-top: 2rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.app-footer p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Hide footer when not in dashboard view */
#quimicos-view.active~.app-footer,
#averia-view.active~.app-footer {
    display: none;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 768px) {
    .header-content {
        height: 64px;
    }

    .header-user span {
        display: none;
    }

    .main-content {
        padding: 1.5rem 0 3rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .form-card {
        padding: 1.5rem;
    }

    .quimicos-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .cart-sidebar {
        max-width: 100%;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .contact-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .contact-btn {
        justify-content: center;
    }
}