/* SwissDent — Portal Dentistas */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.swissdent-portal {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    color: #2c3e50;
    min-height: 70vh;
    background: transparent;
}

/* ---- Screens ---- */
.sd-screen { display: none; }
.sd-screen.active { display: block; }

/* ---- LOGIN ---- */
#sd-login {
    align-items: center; justify-content: center;
    min-height: 72vh; background: transparent;
}
#sd-login.active {
    display: flex;
}
.sd-login-box {
    background: transparent; border-radius: 0; padding: 12px;
    width: 100%; max-width: 340px;
    box-shadow: none;
    text-align: left;
}
.sd-logo        { font-size: 24px; margin-bottom: 6px; font-weight: 700; color: #25313f; }
.sd-login-box h2{ font-size: 15px; font-weight: 500; margin-bottom: 22px; color: #687385; }
.sd-error { background: #fde8e8; color: #c0392b; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

.sd-field { text-align: left; margin-bottom: 18px; }
.sd-field label { display: block; font-size: 12px; font-weight: 600; color: #666; text-transform: uppercase; letter-spacing:.05em; margin-bottom: 6px; }
.sd-field input, .sd-field select, .sd-field textarea {
    width: 100%; padding: 10px 14px; border: 1.5px solid #dde1e4; border-radius: 8px;
    font-size: 15px; transition: border .2s;
}
.sd-field input:focus, .sd-field select:focus, .sd-field textarea:focus {
    outline: none; border-color: #3498db;
}

.sd-pin-wrap { position: relative; }
.sd-pin-wrap input { padding-right: 54px; font-size: 16px; letter-spacing: 0; text-align: left; }
#sd-pin-toggle {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px;
}

/* ---- Buttons ---- */
.sd-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 22px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s;
    text-decoration: none;
}
.sd-btn-primary  { background: #3498db; color: #fff; }
.sd-btn-primary:hover { background: #2980b9; }
.sd-btn-success  { background: #2ecc71; color: #fff; }
.sd-btn-success:hover { background: #27ae60; }
.sd-btn-ghost    { background: transparent; color: #666; border: 1.5px solid #dde1e4; }
.sd-btn-ghost:hover { background: #f4f6f9; }
.sd-btn + .sd-btn { margin-left: 8px; }
#sd-login-btn    { width: 100%; margin-top: 8px; padding: 13px; font-size: 16px; }

/* ---- Header ---- */
.sd-header {
    background: transparent; color: #25313f; padding: 16px 0;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
    border-bottom: 1px solid #eef1f4;
}
.sd-header-left  { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.sd-logo-small   { font-size: 22px; }
.sd-header-right { display: flex; align-items: center; }
.sd-header-right .sd-btn-ghost { color: #425064; border-color: #cfd6df; }
.sd-header-right .sd-btn-ghost:hover { color: #25313f; background: #f5f7fa; }

/* ---- Toolbar ---- */
.sd-toolbar {
    padding: 14px 24px; background: #fff; border-bottom: 1px solid #e8ebee;
    display: flex; gap: 12px; flex-wrap: wrap;
}
.sd-toolbar input[type=search], .sd-toolbar select {
    padding: 8px 14px; border: 1.5px solid #dde1e4; border-radius: 8px; font-size: 14px;
}
.sd-toolbar input[type=search] { flex: 1; min-width: 200px; }
.sd-toolbar select { min-width: 160px; }

/* ---- Appointment List ---- */
.sd-apt-list { padding: 24px; max-width: 960px; margin: 0 auto; }
.sd-loading  { text-align: center; padding: 60px; color: #888; }

.sd-section-title {
    font-size: 13px; font-weight: 700; color: #888;
    text-transform: uppercase; letter-spacing: .07em;
    margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #e8ebee;
}

.sd-apt-card {
    background: #fff; border-radius: 10px; margin-bottom: 10px;
    border: 1.5px solid #e8ebee; display: flex; align-items: center;
    padding: 14px 18px; cursor: pointer; transition: .15s; gap: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.sd-apt-card:hover { border-color: #3498db; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(52,152,219,.15); }
.sd-apt-card.past  { opacity: .75; }

.sd-apt-date  { min-width: 90px; font-weight: 700; font-size: 14px; color: #1a2a4a; }
.sd-apt-time  { min-width: 80px; font-size: 13px; color: #666; }
.sd-apt-main, .sd-apt-info  { flex: 1; min-width: 0; }
.sd-apt-row1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sd-apt-row2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.sd-apt-patient { font-weight: 600; font-size: 15px; }
.sd-apt-title   { font-size: 13px; color: #888; margin-top: 2px; }
.sd-apt-badge   {
    padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
    text-transform: capitalize;
}
.sd-apt-actions, .sd-apt-badges { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.sd-apt-actions { flex-direction: column; min-width: 150px; }
.sd-badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; text-transform: uppercase; white-space: nowrap; }
.sd-apt-hc { font-size: 12px; color: #687385; padding: 2px 8px; border: 1px solid #dfe4ea; border-radius: 999px; background: #f8fafc; }
.sd-greeting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sd-greeting-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.sd-request-box { margin-top: 10px; padding: 10px 12px; border: 1px solid #f0d58a; background: #fff9e8; border-radius: 6px; color: #624b10; font-size: 13px; }
.sd-request-box.rejected { border-color: #f1b8b8; background: #fff1f1; color: #7a2020; }
.sd-request-box.approved { border-color: #bde2c7; background: #f1fbf3; color: #1f6b37; }
.sd-request-line { margin-top: 3px; }
.sd-badge-sync { background: #eef2f7; color: #34495e; }
.sd-badge-pendiente   { background: #fff3cd; color: #856404; }
.sd-badge-confirmada  { background: #d1edde; color: #155724; }
.sd-badge-cancelada   { background: #f8d7da; color: #721c24; }
.sd-badge-completada  { background: #cce5ff; color: #004085; }
.sd-badge-no_asistio  { background: #e2e3e5; color: #383d41; }

.sd-no-results { text-align: center; padding: 60px; color: #aaa; font-size: 16px; }

/* ---- Patient info ---- */
.sd-patient-info {
    margin-top: 14px; padding: 12px 16px; background: #f4f6f9;
    border-radius: 8px; font-size: 14px;
}

/* ---- Modal ---- */
.sd-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 10000; display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.sd-modal-box {
    background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
    max-height: 90vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,.3);
    animation: sd-modal-in .2s ease;
}
@keyframes sd-modal-in {
    from { transform: scale(.96); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.sd-modal-header {
    padding: 20px 24px 16px; border-bottom: 1px solid #e8ebee;
    display: flex; align-items: center; justify-content: space-between;
}
.sd-modal-header h3 { font-size: 18px; }
.sd-modal-close, .sd-modal-close-new {
    background: none; border: none; font-size: 20px; cursor: pointer; color: #888; line-height: 1;
}
.sd-modal-body   { padding: 20px 24px; overflow-y: auto; flex: 1; }
.sd-modal-footer { padding: 16px 24px; border-top: 1px solid #e8ebee; display: flex; justify-content: flex-end; }

.sd-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sd-read-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 16px; }
.sd-field input[readonly] { background: #f8fafc; color: #596579; }
@media (max-width: 500px) { .sd-form-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
    .sd-apt-card { flex-direction: column; align-items: flex-start; }
    .sd-apt-actions { align-items: flex-start; width: 100%; margin-left: 0; }
    .sd-read-fields { grid-template-columns: 1fr; }
    .sd-greeting-row { flex-direction: column; }
    .sd-greeting-actions { justify-content: flex-start; }
}

.sd-feedback { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-top: 14px; }
.sd-feedback.ok    { background: #d1edde; color: #155724; }
.sd-feedback.error { background: #f8d7da; color: #721c24; }

/* ---- Autocomplete ---- */
.sd-autocomplete {
    border: 1.5px solid #dde1e4; border-radius: 8px; margin-top: 4px;
    max-height: 180px; overflow-y: auto; display: none;
    background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.sd-autocomplete.open { display: block; }
.sd-autocomplete-item {
    padding: 10px 14px; cursor: pointer; font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}
.sd-autocomplete-item:hover { background: #f4f6f9; }
.sd-selected-patient {
    margin-top: 8px; padding: 8px 12px; background: #e8f4fd;
    border-radius: 8px; font-size: 14px; font-weight: 600; color: #1a2a4a;
    display: none;
}
.sd-selected-patient.visible { display: block; }
