/* ==========================
   LAYOUT GLOBAL
========================== */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

.app {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

/* ==========================
   HEADER
========================== */

header {
    flex-shrink: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    margin: 0 auto;
}

/* ==========================
   MAIN (FULL HEIGHT)
========================== */

main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#page-scan {
    display: flex;
    flex-flow: column;
    justify-content: center;
}

/* ==========================
   PAGINI FULL-SCREEN
========================== */

.page {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    display: none;
}

.page.active {
    display: block;
}

/* ==========================
   CAMERA
========================== */

.camera-frame {
    height: 260px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-placeholder {
    position: absolute;
    color: var(--text-secondary);
    font-size: 13px;
}

.scan-mode-indicator {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 12px;
    margin-bottom: 12px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    color: white;
}

.scan-mode-scanare { background: #34c759; }
.scan-mode-interogare { background: #0a84ff; }

#page-camera .section-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 auto 12px;
    text-align: center;
}

#page-camera .section-title::after {
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    background-color: #eeeeee;
    margin-top: 6px;
}

#page-camera .section-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 auto 16px;
    text-align: center;
}

/* ==========================
   TAB BAR (FIX JOS)
========================== */

.tabs {
    flex-shrink: 0;
    height: 60px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    color: var(--text-secondary);
    cursor: pointer;
}

.tab.active {
    color: var(--accent);
    font-weight: 600;
}

/* ==========================
   FEEDBACK POPUP
========================== */

.feedback-overlay {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
}

.feedback-overlay.visible {
    display: flex;
}

.feedback-card {
    padding: 24px;
    border-radius: 20px;
    color: white;
    text-align: center;
    width: 80%;
    max-width: 360px;
}

.feedback-card.valid { background: #34c759; }
.feedback-card.invalid { background: #ff3b30; }

.feedback-reason {
    font-size: 14px;
    margin-top: 8px;
    opacity: 0.9;
}

/* ==========================
   INPUT / BUTOANE
========================== */

.input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    margin-bottom: 12px;
    font-size: 16px;
}

.button {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    border: none;
    margin-bottom: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.button.disabled {
    background: var(--border);
    color: var(--text-secondary);
    opacity: 0.5;
    pointer-events: none;
}

.button:active {
    opacity: 0.7;
}

.info-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 12px;
}

/* ==========================
   CONFIRM POPUP
========================== */

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.confirm-box {
    background: var(--card-bg, #fff);
    color: var(--text-color, #000);
    padding: 20px;
    border-radius: 14px;
    width: 80%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.confirm-message {
    font-size: 16px;
    margin-bottom: 20px;
}

.confirm-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.confirm-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    cursor: pointer;
}

.confirm-btn.cancel { background: #d0d0d0; }
.confirm-btn.ok { background: #ff3b30; color: white; }

/* ==========================
   ISTORIC + FILTRE
========================== */

.history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.filter-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: #e0e0e0;
    cursor: pointer;
}

.filter-btn.active {
    background: #007aff;
    color: white;
}

.history-item {
  padding: 12px 5px;
  margin-bottom: 8px;
  border-bottom: 1px solid #555;
}

.settings-group { margin: 10px 0 10px; }

.settings-button.disabled,
.filter-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.history-count {
    background: #007aff;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 6px;
}

.filter-count {
    background: #007aff;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 6px;
}

/* ==========================
   TEMA
========================== */

.theme-toggle {
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--card-bg, #eee);
    color: var(--text-color, #000);
    border: 1px solid var(--border-color, #ccc);
    cursor: pointer;
    font-size: 14px;
}