* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --light: #f8fafc;
    --dark: #0f172a;
    --surface: #ffffff;
    --border: #334155;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Login Page */
.page {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

#mainApp {
    display: none;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-primary);
    padding: 40px 20px;
    text-align: center;
}

.login-header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.login-header p {
    font-size: 0.9em;
    opacity: 0.9;
}

.login-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn:hover {
    background: var(--bg-primary);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-full {
    width: 100%;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #0284c7;
}

.btn-logout {
    background: var(--danger);
    color: white;
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-logout:hover {
    background: #dc2626;
}

.hint {
    text-align: center;
    font-size: 0.85em;
    color: #666;
    margin-top: 15px;
}

.error-message {
    color: var(--danger);
    padding: 12px;
    margin-top: 15px;
    border-radius: 8px;
    background: #fee2e2;
    display: none;
    text-align: center;
}

.error-row td {
    background: #fee2e2;
}

.error-message.show {
    display: block;
}

.success-message {
    color: var(--success);
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 8px;
    background: #dcfce7;
    display: none;
}

.success-message.show {
    display: block;
}

/* Navbar */
.navbar {
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-brand h2 {
    color: var(--primary);
    font-size: 1.5em;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 30px;
    flex: 1;
    margin-left: 40px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: color 0.3s ease;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 20px;
}

#userDisplay {
    font-weight: 500;
    color: var(--text-primary);
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    min-height: calc(100vh - 70px);
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.view.active {
    display: block;
}

.view h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 3em;
}

.stat-content h3 {
    font-size: 1.8em;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-content p {
    color: #666;
    font-size: 0.9em;
}

/* Dashboard Content */
.dashboard-content {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    color: var(--dark);
}

.dashboard-content,
.product-card,
.admin-tab-content,
.charge-card,
.charge-details,
.quote-summary,
.quote-item,
.quote-history,
.admin-form,
.admin-list,
.product-card-body {
    color: var(--dark);
}

.admin-tab-content label,
.admin-tab-content input,
.admin-tab-content select,
.admin-tab-content textarea,
.admin-tab-content table th,
.admin-tab-content table td,
.charge-details p,
.charge-details strong,
.quote-summary p,
.quote-summary span,
.quote-item span,
.quote-item input {
    color: var(--dark);
}

.admin-tab-content input,
.admin-tab-content select,
.charge-details,
.quote-summary,
.quote-item,
.product-card {
    background-color: white;
}

.dashboard-section h3 {
    margin-bottom: 15px;
    color: var(--dark);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg-primary);
}

.table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--dark);
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* Search Section */
.search-section {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.search-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.search-tab {
    padding: 12px 20px;
    border: none;
    background: white;
    cursor: pointer;
    font-weight: 500;
    color: var(--dark);
    transition: all 0.3s ease;
    position: relative;
}

.search-tab.active {
    color: var(--primary);
}

.search-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.search-content {
    display: none;
}

.search-content.active {
    display: block;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.results-container {
    margin-bottom: 20px;
}

.product-item {
    background: var(--light);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-info h4 {
    margin-bottom: 5px;
    color: var(--dark);
}

.product-info p {
    font-size: 0.85em;
    color: #666;
}

.product-price {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--primary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.product-card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 15px;
}

.product-card-header h3 {
    margin-bottom: 5px;
}

.product-code {
    font-size: 0.8em;
    opacity: 0.9;
}

.product-card-body {
    padding: 15px;
}

.product-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.product-detail-label {
    color: #666;
}

.product-detail-value {
    font-weight: 600;
    color: var(--dark);
}

.product-price {
    font-size: 1.5em;
    color: var(--success);
    font-weight: 700;
    margin: 10px 0;
}

.product-actions {
    display: flex;
    gap: 10px;
}

.product-actions button {
    flex: 1;
    padding: 10px;
    font-size: 0.9em;
}

/* Quotes View */
.quotes-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.quote-editor,
.quote-history {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
}

.quote-editor h3,
.quote-history h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.2em;
}

.product-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.product-selector select,
.product-selector input {
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95em;
}

.product-selector select {
    flex: 2;
}

.product-selector input {
    flex: 1;
}

.product-selector button {
    padding: 10px 20px;
}

.quote-items {
    margin: 20px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.quote-item-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 10px;
    background: var(--light);
    padding: 12px;
    font-weight: 600;
    font-size: 0.9em;
    color: var(--dark);
}

.quote-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    font-size: 0.9em;
}

.quote-item:last-child {
    border-bottom: none;
}

.quote-item-name {
    font-weight: 500;
}

.quote-item-remove {
    background: var(--danger);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

.quote-summary {
    margin-top: 20px;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.95em;
}

.summary-row.total {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary);
    border-top: 2px solid var(--border);
    padding-top: 10px;
}

.discount-input {
    width: 60px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.quote-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.quote-actions button {
    flex: 1;
    padding: 12px;
    font-size: 0.9em;
}

.charge-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
}

.charge-card {
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
    color: var(--dark);
}

.charge-card h3 {
    margin-bottom: 20px;
    color: var(--dark);
}

.charge-details {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(51, 65, 85, 0.15);
    margin-bottom: 20px;
    color: var(--dark);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.charge-ticket {
    background: #f8fafc;
    padding: 18px 20px;
    border-radius: 14px;
    border: 1px dashed rgba(51, 65, 85, 0.16);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    margin-bottom: 12px;
}

.charge-ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.12);
    padding-bottom: 10px;
}

.charge-ticket-header strong {
    font-size: 1.05em;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary);
}

.charge-ticket-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.08);
}

.charge-ticket-item:last-child {
    border-bottom: none;
}

.charge-ticket-item span {
    color: var(--dark);
    font-size: 0.95em;
}

.charge-ticket-total {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(51, 65, 85, 0.16);
    display: grid;
    gap: 8px;
}

.charge-ticket-total p {
    display: flex;
    justify-content: space-between;
    font-size: 0.96em;
}

.charge-ticket-total p strong {
    color: var(--dark);
}

.charge-ticket-total p.total {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--success);
}

.charge-details p {
    margin-bottom: 10px;
}

.charge-details-inner {
    display: grid;
    gap: 10px;
}

.charge-items p {
    margin: 6px 0;
    color: #334155;
}

.quote-history {
    color: white;
}

.quote-history .quote-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.quote-history .quote-card-header h4,
.quote-history .quote-date,
.quote-history .quote-card-footer button,
.quote-history strong {
    color: white;
}

.quote-history .quote-status.sent {
    background: rgba(99, 102, 241, 0.25);
    color: #e0e7ff;
}

.quote-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.quote-card-header h4 {
    color: var(--dark);
}

.quote-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
}

.quote-status.draft {
    background: #fef3c7;
    color: #b45309;
}

.quote-status.sent {
    background: #dbeafe;
    color: #1e40af;
}

.quote-status.accepted {
    background: #dcfce7;
    color: #15803d;
}

.quote-date {
    font-size: 0.85em;
    color: #666;
}

.quote-card-footer {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.quote-card-footer button {
    flex: 1;
    padding: 8px;
    font-size: 0.8em;
}

/* Admin Panel */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border);
    background: white;
    padding: 0 25px;
    border-radius: 15px 15px 0 0;
}

.admin-tab {
    padding: 15px 20px;
    border: none;
    background: white;
    cursor: pointer;
    font-weight: 500;
    color: var(--dark);
    transition: all 0.3s ease;
    position: relative;
}

.admin-tab.active {
    color: var(--primary);
}

.admin-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.admin-tab-content {
    display: none;
    background: white;
    padding: 25px;
    border-radius: 0 15px 15px 15px;
    box-shadow: var(--shadow);
}

.admin-tab-content.active {
    display: block;
}

.admin-form {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

/* Sales View */
.sales-container {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.sales-summary {
    margin-bottom: 30px;
}

.summary-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 15px;
    padding: 25px;
    color: white;
    box-shadow: var(--shadow-lg);
}

.summary-card h3 {
    margin-bottom: 15px;
    font-size: 1.3em;
}

.summary-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.summary-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-item .label {
    font-weight: 500;
    font-size: 0.95em;
}

.summary-item .value {
    font-weight: 700;
    font-size: 1.5em;
}

.sales-list {
    margin-top: 30px;
}

.sales-list h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.2em;
}

.sales-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.sales-table thead {
    background: var(--primary);
    color: white;
}

.sales-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.sales-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    color: var(--dark);
}

.sales-table tbody tr:hover {
    background-color: #f5f5f5;
}

.sales-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-form h3 {
    margin-bottom: 20px;
    color: var(--dark);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.select-input {
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}

.admin-list {
    background: rgba(15, 23, 42, 0.96);
    padding: 20px;
    border-radius: 15px;
    color: white;
}

.admin-list h3 {
    margin-bottom: 15px;
    color: white;
}

.admin-list table {
    color: white;
}

.admin-list table th,
.admin-list table td {
    color: white;
}

.admin-list table thead {
    background: rgba(255, 255, 255, 0.08);
}

/* Action Buttons in Tables */
.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 5px;
}

.action-btn.edit {
    background: var(--info);
    color: white;
}

.action-btn.edit:hover {
    background: #0284c7;
}

.action-btn.delete {
    background: var(--danger);
    color: white;
}

.action-btn.delete:hover {
    background: #dc2626;
}

/* Modal (para editar productos) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: var(--dark);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-form button {
    padding: 12px;
    font-size: 1em;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }

    .quotes-container {
        grid-template-columns: 1fr;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .quote-item-header,
    .quote-item {
        grid-template-columns: 1fr;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar input,
    .search-bar button {
        width: 100%;
    }

    .admin-tabs {
        flex-wrap: wrap;
    }
}

@media print {
    body {
        background: white;
    }

    .navbar,
    .btn-logout,
    .quote-actions,
    .search-section,
    .admin-tabs,
    .admin-form {
        display: none;
    }
}
