/* =====================================================
   ESTILOS PRINCIPALES - CLIENTE A2UI
   ===================================================== */

:root {
    --primary: #1a365d;
    --primary-light: #2b4c7e;
    --secondary: #3182ce;
    --accent: #38a169;
    --danger: #e53e3e;
    --warning: #d69e2e;
    --gray-50: #f7fafc;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #a0aec0;
    --gray-500: #718096;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* =====================================================
   LAYOUT PRINCIPAL
   ===================================================== */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-header .logo {
    width: 48px;
    height: 48px;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.app-header .subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* =====================================================
   CHAT CONTAINER
   ===================================================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    background: var(--secondary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant {
    background: var(--gray-100);
    color: var(--gray-800);
    align-self: flex-start;
    border-bottom-left-radius: 0.25rem;
}

.message.system {
    background: var(--gray-200);
    color: var(--gray-600);
    align-self: center;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

/* =====================================================
   TYPING INDICATOR
   ===================================================== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* =====================================================
   INPUT AREA
   ===================================================== */
.chat-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--gray-200);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--gray-300);
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--secondary);
}

.send-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--secondary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-button:hover {
    background: var(--primary);
}

.send-button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

/* =====================================================
   COMPONENTES A2UI
   ===================================================== */

/* Equipment Card */
.equipment-card {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0.5rem 0;
}

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

.equipment-card .brand-model {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.equipment-card .serial {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.equipment-card .badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.equipment-card .badge.warranty-active {
    background: #c6f6d5;
    color: #22543d;
}

.equipment-card .badge.warranty-expired {
    background: #fed7d7;
    color: #742a2a;
}

.equipment-card .info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.equipment-card .info-item {
    display: flex;
    flex-direction: column;
}

.equipment-card .info-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.equipment-card .info-value {
    font-weight: 500;
    color: var(--gray-700);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid var(--gray-200);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.action-button:hover {
    border-color: var(--secondary);
    background: var(--gray-50);
}

.action-button.primary {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.action-button.primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.action-button .icon {
    font-size: 1.5rem;
}

.action-button .label {
    font-weight: 500;
}

/* Problem Type Selector */
.problem-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.problem-option {
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid var(--gray-200);
    background: white;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.problem-option:hover {
    border-color: var(--secondary);
}

.problem-option.selected {
    border-color: var(--secondary);
    background: #ebf8ff;
}

.problem-option .icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.problem-option .label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Report Summary Card */
.report-summary {
    background: linear-gradient(135deg, var(--accent) 0%, #2f855a 100%);
    color: white;
    border-radius: 1rem;
    padding: 1.25rem;
    margin: 0.5rem 0;
}

.report-summary .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.report-summary .report-number {
    font-size: 1.25rem;
    font-weight: 700;
}

.report-summary .status {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
    font-size: 0.75rem;
}

.report-summary .details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.report-summary .detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.report-summary .detail-label {
    opacity: 0.9;
}

/* Timeline History */
.timeline {
    margin: 0.5rem 0;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding-bottom: 1rem;
    border-left: 2px solid var(--gray-200);
    margin-left: 0.5rem;
    padding-left: 1rem;
}

.timeline-item:last-child {
    border-left-color: transparent;
}

.timeline-item .dot {
    width: 12px;
    height: 12px;
    background: var(--secondary);
    border-radius: 50%;
    margin-left: -1.4rem;
    margin-top: 0.25rem;
}

.timeline-item .content {
    flex: 1;
}

.timeline-item .date {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.timeline-item .title {
    font-weight: 500;
}

.timeline-item .description {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Warranty Status Card */
.warranty-card {
    border-radius: 1rem;
    padding: 1rem;
    margin: 0.5rem 0;
}

.warranty-card.active {
    background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%);
}

.warranty-card.expired {
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
}

.warranty-card .status-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.warranty-card .title {
    font-size: 1.125rem;
    font-weight: 600;
}

.warranty-card .info {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Photo Uploader */
.photo-uploader {
    margin: 0.5rem 0;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.photo-item {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.add-photo-button {
    aspect-ratio: 1;
    border: 2px dashed var(--gray-300);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-500);
    transition: all 0.2s;
}

.add-photo-button:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

/* Confirmation Message */
.confirmation-message {
    border-radius: 1rem;
    padding: 1rem;
    margin: 0.5rem 0;
}

.confirmation-message.success {
    background: #c6f6d5;
    border-left: 4px solid var(--accent);
}

.confirmation-message.warning {
    background: #fefcbf;
    border-left: 4px solid var(--warning);
}

.confirmation-message.error {
    background: #fed7d7;
    border-left: 4px solid var(--danger);
}

.confirmation-message.info {
    background: #bee3f8;
    border-left: 4px solid var(--secondary);
}

.confirmation-message .title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* Dynamic Form */
.dynamic-form {
    margin: 0.5rem 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--gray-700);
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.form-submit {
    width: 100%;
    padding: 0.875rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.form-submit:hover {
    background: var(--primary);
}

/* =====================================================
   LOADING & STATES
   ===================================================== */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    color: var(--gray-500);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 2rem;
    text-align: center;
}

.error-screen .icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-screen .title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.error-screen .message {
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.retry-button {
    padding: 0.75rem 1.5rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
}

/* =====================================================
   QUICK SUGGESTIONS
   ===================================================== */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.suggestion-chip {
    padding: 0.5rem 0.875rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: var(--gray-200);
    border-color: var(--gray-300);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (min-width: 481px) {
    .app-container {
        margin: 1rem auto;
        border-radius: 1rem;
        min-height: calc(100vh - 2rem);
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 0.875rem 1rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .problem-selector {
        grid-template-columns: 1fr 1fr;
    }
}
