/* ============================================================
   EnergyExperts — generic CSV upload dialog (assets/js/ee-csv-upload-dialog.js)

   Uses the tokens of the account dashboard (ee-create-account.css :root):
   --surface, --background, --border-light, --border-medium, --text-primary,
   --text-secondary, --radius, --radius-large, --shadow-lg, --transition.
   No colour, radius or shadow is invented here, and the buttons and inputs are
   the existing .btn / .form-input / .form-label / .form-hint classes.
   ============================================================ */

.ee-csv-dialog {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgb(0 0 0 / 0.35);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.ee-csv-dialog-box {
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    max-height: min(86vh, 900px);
    background: var(--background, #ffffff);
    border-radius: var(--radius-large, 20px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.1));
    overflow: hidden;
}

/* ---------- head / foot ---------- */

.ee-csv-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 1.5rem 2rem 1rem;
}

.ee-csv-dialog-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.ee-csv-dialog-close {
    border: none;
    background: none;
    padding: 0 4px;
    font-family: inherit;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: var(--transition, all 0.2s);
}

.ee-csv-dialog-close:hover { color: var(--text-primary, #1a1a1a); }

.ee-csv-dialog-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 2rem 1rem;
}

.ee-csv-dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 1rem 2rem 1.5rem;
    border-top: 1px solid var(--border-light, #e5e7eb);
}

/* ---------- sections ---------- */

.ee-csv-dialog-intro,
.ee-csv-dialog-hint {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-secondary, #6b7280);
}

/* Same reason as in ee-finance-settings.css: the portal reset sets
   `section { display: block }`, which beats the user agent rule for the
   hidden attribute. A section hidden by script must say so in author CSS. */
.ee-csv-dialog-section[hidden] { display: none; }

.ee-csv-dialog-section { margin-bottom: 1.5rem; }
.ee-csv-dialog-section:empty { margin-bottom: 0; }

.ee-csv-dialog-sectionhead {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.ee-csv-dialog-subtitle {
    flex: 1 1 auto;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.ee-csv-dialog-select { width: auto; min-width: 180px; }
.ee-csv-dialog-select[hidden] { display: none; }

/* ---------- column table ---------- */

.ee-csv-dialog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.ee-csv-dialog-table th,
.ee-csv-dialog-table td {
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.ee-csv-dialog-table th {
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
}

.ee-csv-dialog-col {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    white-space: nowrap;
}

.ee-csv-dialog-colhint {
    display: block;
    margin-top: 2px;
    color: var(--text-secondary, #6b7280);
}

.ee-csv-dialog-scroll {
    max-height: 200px;
    overflow: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius, 12px);
}

/* ---------- drop zone ---------- */

.ee-csv-dropzone {
    position: relative;
    border: 2px dashed var(--border-medium, #d1d5db);
    border-radius: var(--radius, 12px);
    background: var(--surface, #f9f9f9);
    transition: var(--transition, all 0.2s);
}

.ee-csv-dropzone.is-over,
.ee-csv-dropzone:hover { border-color: var(--text-secondary, #6b7280); }

.ee-csv-dropzone.has-file { border-style: solid; }

.ee-csv-dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ee-csv-dropzone-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
}

.ee-csv-dropzone-title {
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.ee-csv-dropzone-sub {
    font-size: 0.8125rem;
    color: var(--text-secondary, #6b7280);
}

.ee-csv-dialog-file {
    margin: 0.5rem 0 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary, #6b7280);
}

.ee-csv-dialog-file:empty { display: none; }

/* ---------- fields ---------- */

.ee-csv-dialog-fields,
.ee-csv-dialog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.5rem;
}

.ee-csv-dialog-fields:empty,
.ee-csv-dialog-grid:empty { display: none; }

.ee-csv-dialog-field .form-label { margin-bottom: 0.25rem; }
.ee-csv-dialog-field .form-hint { margin-top: 0.25rem; }

/* ---------- status ---------- */

.ee-csv-dialog-status {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary, #6b7280);
}

.ee-csv-dialog-status:empty { display: none; }
.ee-csv-dialog-status.is-success { color: var(--success, #10b981); }
.ee-csv-dialog-status.is-error { color: var(--error, #ef4444); }

@media (max-width: 640px) {
    .ee-csv-dialog { padding: 0; }
    .ee-csv-dialog-box { max-height: 100vh; border-radius: 0; }
    .ee-csv-dialog-head,
    .ee-csv-dialog-body,
    .ee-csv-dialog-foot { padding-left: 1.25rem; padding-right: 1.25rem; }
}
