/* Variables */
:root {
    --color-primary: #b8860b;
    --color-primary-dark: #8b6508;
    --color-danger: #dc3545;
    --color-success: #28a745;
    --color-warning: #ffc107;
    --color-bg: #f5f5f5;
    --color-card: #ffffff;
    --color-border: #e0e0e0;
    --color-text: #333333;
    --color-text-muted: #666666;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); font-size: 0.875rem; }

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    text-align: center;
    padding: 48px;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-box h1 {
    margin-bottom: 8px;
    color: var(--color-primary);
}

.login-box p {
    margin-bottom: 24px;
    color: var(--color-text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background: var(--color-bg);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn:focus:not(:focus-visible) {
    outline: none;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--color-border);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-email {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    padding: 16px 24px 0;
    background: white;
    border-bottom: 1px solid var(--color-border);
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--color-text);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Sub Tabs */
.sub-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.sub-tab {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sub-tab:hover {
    background: var(--color-bg);
}

.sub-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* Main Content */
.main-content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.section-header h2 {
    font-size: 1.5rem;
    flex: 1;
}

/* Restaurantes Grid */
.restaurantes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.restaurante-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.restaurante-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.restaurante-card h3 {
    margin-bottom: 8px;
}

.restaurante-card .meta {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Card */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card h3 {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.card h4 {
    margin: 20px 0 12px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

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

.card-header h3 {
    margin: 0;
    padding: 0;
    border: none;
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* Color Input */
.color-input {
    display: flex;
    gap: 8px;
}

.color-input input[type="color"] {
    width: 48px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.color-input input[type="text"] {
    flex: 1;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* File Upload */
.file-upload {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-upload img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

/* Fondo Options */
.fondo-options {
    margin-top: 16px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

/* Menus List */
.menus-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.menu-item:hover {
    background: #eee;
}

.menu-item .drag-handle {
    cursor: grab;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    user-select: none;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.menu-item .drag-handle:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.menu-item .drag-handle:active {
    cursor: grabbing;
}

/* Drag & Drop States */
.menu-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.menu-item.drag-over {
    border: 2px dashed var(--color-primary);
    background: rgba(184, 134, 11, 0.1);
}

.menu-item.drag-over-top {
    border-top: 3px solid var(--color-primary);
}

.menu-item.drag-over-bottom {
    border-bottom: 3px solid var(--color-primary);
}

.menu-item .icon {
    font-size: 1.5rem;
}

.menu-item .info {
    flex: 1;
}

.menu-item .nombre {
    font-weight: 500;
}

.menu-item .archivo {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.menu-item .badges {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 2px 8px;
    font-size: 0.7rem;
    border-radius: 10px;
    font-weight: 500;
}

.badge-destacado {
    background: #ffeeba;
    color: #856404;
}

.badge-procesando {
    background: #cce5ff;
    color: #004085;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-spinner {
    width: 10px;
    height: 10px;
    border: 2px solid #cce5ff;
    border-top-color: #004085;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.badge-error {
    background: #f8d7da;
    color: #721c24;
}

.badge-inactivo {
    background: #e2e3e5;
    color: #383d41;
}

.menu-item .actions {
    display: flex;
    gap: 8px;
}

.menu-item .toggle {
    width: 44px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-item .toggle.active {
    background: var(--color-success);
}

.menu-item .toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.menu-item .toggle.active::after {
    transform: translateX(20px);
}

/* Table */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
}

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

.table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.table td {
    font-size: 0.875rem;
}

.table tr:last-child td {
    border-bottom: none;
}

/* Tags List */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.875rem;
}

.tag .delete {
    cursor: pointer;
    color: var(--color-danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--color-text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.modal-body {
    padding: 20px;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: #333;
    color: white;
    border-radius: var(--radius);
    font-size: 0.875rem;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

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

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    gap: 16px;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
}

.loading-overlay p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Upload Progress */
.upload-progress {
    margin-top: 16px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.upload-progress-label {
    font-weight: 500;
}

.upload-progress-stats {
    color: var(--color-text-muted);
}

.upload-progress-bar {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.2s ease;
    width: 0%;
}

.upload-progress-fill.complete {
    background: var(--color-success);
}

.upload-progress-fill.processing {
    background: var(--color-warning);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.upload-progress-message {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Section loading state */
.section-loading {
    position: relative;
    min-height: 200px;
}

.section-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.section-loading .card {
    opacity: 0.5;
    pointer-events: none;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg) 50%, var(--color-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-input {
    height: 38px;
    margin-bottom: 16px;
}

/* Confirmation Modal Styles */
.confirm-modal-body {
    text-align: center;
    padding: 12px 0;
}

.confirm-modal-body .confirm-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.confirm-modal-body .confirm-icon.warning {
    color: var(--color-warning);
}

.confirm-modal-body .confirm-icon.danger {
    color: var(--color-danger);
}

.confirm-modal-body .confirm-message {
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: 8px;
}

.confirm-modal-body .confirm-detail {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Preview Panel Styles */
.preview-container {
    position: relative;
    background: #1a1a2e;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.preview-header h4 {
    margin: 0;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-actions button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.preview-actions button:hover {
    background: rgba(255,255,255,0.2);
}

.preview-frame {
    width: 100%;
    height: 400px;
    border: none;
    background: white;
}

.preview-device-frame {
    max-width: 375px;
    margin: 0 auto;
    padding: 16px;
}

/* Improved transitions */
.menu-item {
    transition: all 0.2s ease, transform 0.15s ease;
}

.restaurante-card {
    transition: all 0.2s ease, transform 0.15s ease;
}

/* Better button feedback */
.btn {
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary:active {
    background: var(--color-primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .header-right {
        flex-direction: column;
    }

    .tabs {
        overflow-x: auto;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}
