/* Variables globales */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --light: #f1f5f9;
    --dark: #0f172a;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s;
}

.nav-link:hover {
    color: var(--primary);
    background: var(--light);
}

.nav-link.active {
    color: var(--primary);
    background: #dbeafe;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 2rem;
    border-left: 1px solid var(--border);
}

/* Main Content */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* Hero Search */
.hero-search {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
    text-align: center;
}

.hero-search h2 {
    font-size: 2rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.hero-search p {
    color: var(--secondary);
    margin-bottom: 2rem;
}

.search-form {
    max-width: 800px;
    margin: 0 auto;
}

.search-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-row input {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.search-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.filters-row input {
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Botones */
.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-icon {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.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-icon {
    background: var(--light);
    color: var(--dark);
    padding: 0.75rem;
    font-size: 1.2rem;
}

/* Resultados */
.resultados {
    min-height: 200px;
}

.resultados-header {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.resultados-header h3 {
    color: var(--dark);
}

.piezas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.pieza-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    cursor: pointer;
}

.pieza-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.pieza-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.pieza-header h4 {
    font-size: 1.2rem;
    color: var(--dark);
    flex: 1;
}

.precio {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.pieza-info p {
    margin: 0.5rem 0;
    color: var(--secondary);
    font-size: 0.9rem;
}

.pieza-info strong {
    color: var(--dark);
}

.repuestero-info {
    margin-top: 1rem;
}

.repuestero-info hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.repuestero-info a {
    color: var(--primary);
    text-decoration: none;
}

.repuestero-info a:hover {
    text-decoration: underline;
}

.pieza-actions {
    margin-top: 1rem;
}

.pieza-actions button {
    width: 100%;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-nueva { background: #dbeafe; color: #1e40af; }
.badge-usado { background: #fef3c7; color: #92400e; }
.badge-reconstruido { background: #e0e7ff; color: #4338ca; }
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-cotizada { background: #dbeafe; color: #1e40af; }
.badge-cerrada { background: #f3f4f6; color: #6b7280; }
.badge-aceptada { background: #d1fae5; color: #065f46; }
.badge-rechazada { background: #fee2e2; color: #991b1b; }

/* Repuesteros Cercanos */
.repuesteros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.repuestero-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.repuestero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.repuestero-header h4 {
    color: var(--dark);
    font-size: 1.2rem;
}

.distancia {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
}

.repuestero-detalles p {
    margin: 0.5rem 0;
    color: var(--secondary);
}

.descripcion {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-style: italic;
}

.repuestero-actions {
    margin-top: 1rem;
}

/* Solicitudes */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.solicitudes-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.solicitud-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.solicitud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.solicitud-header h4 {
    color: var(--dark);
    font-size: 1.2rem;
}

.solicitud-info p {
    margin: 0.5rem 0;
    color: var(--secondary);
}

.cotizaciones-list {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.cotizaciones-list h5 {
    color: var(--dark);
    margin-bottom: 1rem;
}

.cotizacion-item {
    background: var(--light);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.cotizacion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.cotizacion-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.cotizacion-actions button {
    flex: 1;
}

/* Chat */
.chat-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto;
}

.chat-header {
    background: var(--primary);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.chat-header h2 {
    margin-bottom: 0.5rem;
}

.chat-header p {
    opacity: 0.9;
}

.chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f8fafc;
}

.message {
    margin-bottom: 1rem;
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: white;
    color: var(--dark);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--primary);
}

.image-upload-area {
    padding: 1.5rem;
    background: var(--light);
    text-align: center;
    border-top: 1px solid var(--border);
}

.image-upload-area p {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.preview-image {
    max-width: 300px;
    max-height: 300px;
    margin: 1rem auto;
    border-radius: 8px;
    display: none;
}

/* Modales */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    color: var(--dark);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
}

.btn-close:hover {
    color: var(--danger);
}

/* Formularios */
form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Estados */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--secondary);
    font-size: 1.1rem;
}

.hint {
    text-align: center;
    padding: 2rem;
    color: var(--secondary);
    font-style: italic;
}

.error {
    background: #fee2e2;
    color: #991b1b;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .user-menu {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 1rem;
    }
    
    .hero-search {
        padding: 1.5rem;
    }
    
    .hero-search h2 {
        font-size: 1.5rem;
    }
    
    .search-row {
        flex-direction: column;
    }
    
    .filters-row {
        grid-template-columns: 1fr;
    }
    
    .piezas-grid,
    .repuesteros-grid {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .section-header button {
        width: 100%;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-messages {
        height: 400px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .cotizacion-actions {
        flex-direction: column;
    }
}
