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

:root {
    --primary:        #5D43E5;
    --primary-hover:  #523bc3;
    --primary-light:  rgba(93, 67, 229, 0.12);
    --bg:             #181c27;
    --surface:        #0D111D;
    --surface-2:      #141928;
    --border:         #2a2f3e;
    --border-light:   #D4DCE6;
    --headline:       #ebebeb;
    --text:           #c8cdd8;
    --text-dim:       #6b7280;
    --primary-text:   #F2F7FE;
    --success:        #22c55e;
    --success-bg:     rgba(34, 197, 94, 0.1);
    --error:          #ef4444;
    --error-bg:       rgba(239, 68, 68, 0.1);
    --claro:          #E8001D;
    --movistar:       #009900;
    --personal:       #0066CC;
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */
body {
    font-family: 'Work Sans', sans-serif;
    background: var(--bg);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 2rem 1rem;
    color: var(--text);
}

*::selection {
    background: var(--primary);
    color: var(--primary-text);
}

/* ─── App Wrapper ────────────────────────────────────────────────────────────── */
.app-wrapper {
    width: 100%;
    max-width: 38rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--headline);
    font-size: 1.5rem;
    font-weight: 600;
}

.app-logo svg {
    stroke: var(--primary);
}

.app-subtitle {
    font-size: 0.9rem;
    color: var(--text-dim);
    padding-left: 2.4rem;
}

/* ─── Card / Form ────────────────────────────────────────────────────────────── */
.dropzone-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.form-header h2 {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--headline);
    margin-bottom: 0.3rem;
}

.form-header p {
    font-size: 1rem;
    color: var(--text-dim);
}

/* ─── Company Badge ──────────────────────────────────────────────────────────── */
.company-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.6rem 0.9rem;
    gap: 0.75rem;
    animation: fadeIn 0.2s ease;
}

.company-badge-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.company-label {
    white-space: nowrap;
}

.company-pill {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.2s;
}

.btn-override {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-override:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ─── Company Selector ───────────────────────────────────────────────────────── */
.company-selector {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.9rem 1rem;
    animation: fadeIn 0.2s ease;
}

.selector-label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.company-buttons {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.company-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    justify-content: center;
    min-width: 7rem;
}

.company-btn:hover {
    border-color: var(--primary);
    color: var(--headline);
    background: var(--primary-light);
}

.company-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-text);
    font-weight: 500;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-claro    { background: var(--claro); }
.dot-movistar { background: var(--movistar); }
.dot-personal { background: var(--personal); }

/* ─── Dropzone Area ──────────────────────────────────────────────────────────── */
.dropzone-area {
    position: relative;
    min-height: 14rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed var(--border-light);
    border-radius: 1rem;
    cursor: pointer;
    padding: 1.5rem 1rem;
    transition: border-color 0.25s, background 0.25s;
}

.dropzone-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone--over {
    border-color: var(--primary) !important;
    background: var(--primary-light) !important;
}

.dropzone-area [type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.file-upload-icon svg {
    width: 5rem;
    height: 5rem;
    stroke: var(--text-dim);
    margin-bottom: 0.75rem;
    transition: stroke 0.2s;
}

.dropzone-area:hover .file-upload-icon svg,
.dropzone--over .file-upload-icon svg {
    stroke: var(--primary);
}

.file-placeholder {
    font-size: 1rem;
    color: var(--text-dim);
}

/* ─── File List ──────────────────────────────────────────────────────────────── */
.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-height: 12rem;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.45rem 0.75rem;
    text-align: left;
    font-size: 0.875rem;
}

.file-item--invalid {
    border-color: var(--error);
    opacity: 0.7;
}

.file-ext-badge {
    background: var(--primary-light);
    color: var(--primary-text);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.file-name {
    flex: 1;
    color: var(--headline);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-dim);
    flex-shrink: 0;
    font-size: 0.8rem;
}

.file-error {
    color: var(--error);
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* ─── Description Row ────────────────────────────────────────────────────────── */
.dropzone-description {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-dim);
    padding: 0 0.25rem;
}

/* ─── Progress ───────────────────────────────────────────────────────────────── */
.upload-progress {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
}

/* ─── Result ─────────────────────────────────────────────────────────────────── */
.upload-result {
    border-radius: 0.75rem;
    padding: 0.9rem 1rem;
    font-size: 0.9rem;
    animation: fadeIn 0.25s ease;
}

.upload-result--success {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--success);
}

.upload-result--error {
    background: var(--error-bg);
    border: 1px solid var(--error);
    color: var(--error);
}

.result-inner {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.result-inner svg {
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.upload-result code {
    font-family: 'Courier New', monospace;
    font-size: 0.82em;
    background: rgba(255,255,255,0.1);
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}

.upload-result strong {
    font-weight: 600;
}

/* ─── Actions ────────────────────────────────────────────────────────────────── */
.dropzone-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: 0.25rem;
}

.dropzone-help {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-dim);
    cursor: default;
    user-select: none;
}

.action-buttons {
    display: flex;
    gap: 0.6rem;
}

.action-buttons button {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.55rem 1.25rem;
    border-radius: 0.6rem;
    min-height: 2.75rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

button[type='reset'] {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border) !important;
}

button[type='reset']:hover {
    border-color: var(--border-light) !important;
    color: var(--headline);
}

button[type='submit'] {
    background: var(--primary);
    color: var(--primary-text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

button[type='submit']:hover:not(:disabled) {
    background: var(--primary-hover);
}

button[type='submit']:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ─── Animaciones ────────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── CSV Panel ──────────────────────────────────────────────────────────────── */
.csv-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.csv-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}

.csv-panel-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--success);
    flex: 1;
    min-width: 0;
}

.csv-panel-info > svg {
    flex-shrink: 0;
    stroke: var(--success);
}

.csv-panel-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.csv-panel-text span {
    color: var(--headline);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.csv-filename {
    font-size: 0.8rem !important;
    color: var(--text-dim) !important;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-download-csv {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    padding: 0.55rem 1.1rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-download-csv:hover {
    background: #16a34a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-download-csv:active {
    transform: translateY(0);
}

/* ─── Tabla CSV ──────────────────────────────────────────────────────────────── */
.csv-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 420px;
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    white-space: nowrap;
}

.csv-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.csv-table thead tr {
    background: var(--surface-2);
}

.csv-table th {
    padding: 0.6rem 0.9rem;
    text-align: left;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.csv-table th:last-child {
    border-right: none;
}

.csv-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.csv-table tbody tr:hover {
    background: var(--surface-2);
}

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

.csv-table td {
    padding: 0.45rem 0.9rem;
    color: var(--text);
    border-right: 1px solid var(--border);
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csv-table td:last-child {
    border-right: none;
}

.more-rows td {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    padding: 0.6rem;
    background: var(--surface-2);
}

.csv-panel-footer {
    padding: 0.6rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .dropzone-box { padding: 1.25rem; }
    .company-buttons { flex-direction: column; }
    .dropzone-actions { flex-direction: column; align-items: stretch; }
    .action-buttons { flex-direction: row; }
    .dropzone-help { justify-content: center; }
    .csv-panel-header { flex-direction: column; align-items: flex-start; }
    .btn-download-csv { width: 100%; justify-content: center; }
}
