/* ============================================
   OTIC Cargo de Entrega - Premium Stylesheet
   ============================================ */

/* === CSS Custom Properties === */
:root {
    /* Colores personalizados - CAFED Logo */
    --main-red:     #ee3627;
    --main-gray:    #e7e7ee;
    --main-blue:    #1454a1;
    
    --primary-50:  #f0f4f9;
    --primary-100: #e0ebf5;
    --primary-200: #c7d9ed;
    --primary-300: #a5c0e0;
    --primary-400: #7fa5d0;
    --primary-500: #1454a1;
    --primary-600: #0d3470;
    --primary-700: #082550;
    --primary-800: #051a38;
    --primary-900: #030f20;

    --accent-400: #ee3627;
    --accent-500: #d62a1f;
    --accent-600: #be2318;

    --success-400: #34d399;
    --success-500: #10b981;
    --success-600: #059669;

    --error-400: #f87171;
    --error-500: #ef4444;

    --warning-400: #fbbf24;
    --warning-500: #f59e0b;

    --surface-0:   #ffffff;
    --surface-50:  #f9fafb;
    --surface-100: #f3f4f6;
    --surface-200: #e5e7eb;
    --surface-300: #d1d5db;
    --surface-400: #9ca3af;
    --surface-500: #6b7280;

    --text-primary:   #1f2937;
    --text-secondary: #4b5563;
    --text-muted:     #9ca3af;

    --border-color:   rgba(20, 84, 161, 0.15);
    --border-hover:   rgba(20, 84, 161, 0.35);

    --glass-bg:       rgba(255, 255, 255, 0.9);
    --glass-border:   rgba(20, 84, 161, 0.12);

    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(20, 84, 161, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8f9fa;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Background Particles === */
.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 70%);
    animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, -2%) rotate(1deg); }
    66% { transform: translate(-1%, 1%) rotate(-1deg); }
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    animation: float linear infinite;
}

@keyframes float {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* === App Container === */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Header === */
.app-header {
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.3));
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5)); }
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-300), var(--accent-400));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--surface-200);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-500);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* === Form Card === */
.form-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    transition: box-shadow var(--transition-slow);
}

.form-card:hover {
    box-shadow: var(--shadow-xl), 0 0 30px rgba(99, 102, 241, 0.2);
}

/* === Card Header === */
.card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 28px 32px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05));
    border-bottom: 1px solid var(--glass-border);
}

.card-header-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-600), var(--accent-600));
    border-radius: var(--radius-md);
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.card-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === Form Sections === */
.form-section {
    padding: 28px 32px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-300);
}

.section-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    color: var(--primary-400);
    flex-shrink: 0;
}

.section-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* === Form Grid === */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* === Form Groups === */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

.required {
    color: var(--error-400);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-200);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-base);
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.form-input:hover {
    border-color: var(--border-hover);
}

.form-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: var(--surface-100);
}

.form-input.error {
    border-color: var(--error-500);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* === Select (Dropdown) === */
select.form-input {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

select.form-input:hover {
    border-color: var(--border-hover);
}

select.form-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select.form-input option {
    background: var(--surface-200);
    color: var(--text-primary);
    padding: 8px 12px;
}

select.form-input option:hover {
    background: var(--primary-600);
    color: white;
}

select.form-input option:checked {
    background: var(--primary-600);
    color: white;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper .form-input {
    padding-right: 160px;
}

.input-suffix {
    position: absolute;
    right: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
}

.input-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* === Toggle Switch === */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-400);
    border-radius: 13px;
    transition: all var(--transition-base);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition-base);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* === Credential Items === */
.credential-item {
    background: var(--surface-100);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 12px;
    transition: all var(--transition-base);
}

.credential-item:hover {
    border-color: var(--border-hover);
    background: var(--surface-150, var(--surface-200));
}

.credential-item.active {
    border-color: var(--primary-500);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.1);
}

.credential-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
}

.credential-label {
    display: flex;
    flex-direction: column;
}

.credential-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.credential-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.credential-input {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.compartido-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--success-400);
}

/* === Preview Section === */
.preview-section {
    background: rgba(99, 102, 241, 0.03);
}

.preview-icon {
    background: rgba(139, 92, 246, 0.1) !important;
    color: var(--accent-400) !important;
}

.preview-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.preview-table thead {
    background: var(--surface-300);
}

.preview-table th {
    padding: 12px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.preview-table td {
    padding: 12px 16px;
    text-align: center;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

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

/* === Buttons === */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 24px 32px;
    background: var(--surface-50);
    border-top: 1px solid var(--border-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.btn:hover::after {
    transform: translateX(100%);
}

.btn-secondary {
    background: var(--surface-300);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--surface-400);
    color: var(--text-primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--accent-600));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-600), var(--accent-600));
    border-radius: var(--radius-sm);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* === Footer === */
.app-footer {
    text-align: center;
    padding: 32px 20px;
    margin-top: auto;
}

.app-footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    min-width: 320px;
    max-width: 450px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    transition: all var(--transition-base);
}

.toast:hover {
    transform: translateX(-4px);
}

.toast.toast-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-400);
}

.toast.toast-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error-400);
}

.toast.toast-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning-400);
}

.toast.toast-info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary-400);
}

.toast.toast-out {
    animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100px); }
}

.toast-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* === Responsive === */
@media (max-width: 640px) {
    .app-container {
        padding: 12px;
    }

    .card-header,
    .form-section,
    .form-actions {
        padding-left: 20px;
        padding-right: 20px;
    }

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

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .input-wrapper .form-input {
        padding-right: 12px;
    }

    .input-suffix {
        display: none;
    }
}
