* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Fixăm ecranul complet la înălțimea ferestrei dinamic (dvh), fără scroll exterior */
html, body {
    height: 100vh;
    height: 100dvh; /* Adaptează înălțimea dinamic în browserele mobile când apare/dispare bara de adrese */
    overflow: hidden;
    background-color: #f4f7f6;
    color: #333;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

/* Containerul principal se mulează pe fereastră și NU o depășește niciodată */
.container {
    width: 100%;
    max-width: 900px;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    background: #7da7dc;
    padding: 10px 20px 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Asigură că nimic nu depășește chenarul albastru */
}

/* Elementele fixe nu se micșorează */
.admin-bar, 
.app-header, 
.adsense-container, 
.search-box, 
.toolbar, 
.status-section,
.app-footer {
    flex-shrink: 0;
}

.admin-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

/* Titlul principal */
.app-header h1 {
    text-align: center;
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 4px;
    font-size: 24px;
}

/* AdSense Box */
.adsense-container {
    margin-bottom: 6px;
    text-align: center;
}

/* Casetă Căutare */
.search-box {
    position: relative;
    margin-bottom: 6px;
}

.search-box input {
    width: 100%;
    padding: 6px 35px 6px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Butonul X de ștergere căutare */
.btn-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: none;
}

.btn-clear.visible {
    display: block;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
}

/* Secțiunea listei preia DINAMIC spațiul rămas liber */
.list-section {
    flex: 1 1 0%;
    min-height: 0; /* Permite redimensionarea sub conținut pe orice ecran */
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    overflow: hidden;
}

/* Listbox-ul umple secțiunea și gestionează scroll-ul intern */
.subject-listbox {
    width: 100%;
    height: 100% !important;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    overflow-y: auto;
/* Oprește selectarea textului pe toată lista */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Fiecare rând face word-wrap corect */
.subject-item {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    white-space: normal !important;
    word-break: break-word;
/* Dezactivează selectarea textului la click / dublu-click / atingere lungă */
    -webkit-user-select: none; /* Safari / Chrome pe iOS & Android */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE / Edge mai vechi */
    user-select: none;         /* Standard modern */
}

.subject-item:hover {
    background-color: #f0f4f8;
}

.subject-item.selected {
    background: #3498db !important;
    color: white !important;
}

.deselect-wrapper {
    margin-top: 2px;
    flex-shrink: 0;
}

/* Câmp Descriere (Ascuns definitiv) */
.description-section {
    display: none !important;
}

/* Status Text Simplu */
.status-section {
    margin-bottom: 2px;
}

.status-input {
    background: transparent !important;
    border: none !important;
    padding: 2px 0 !important;
    font-size: 13px;
    color: #2c3e50;
    font-weight: 500;
    box-shadow: none !important;
    outline: none !important;
}

/* Butoane */
.btn {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.btn-primary { background: #3498db; color: #fff; }
.btn-success { background: #2ecc71; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-secondary { background: #95a5a6; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-sm { padding: 3px 6px; font-size: 11px; }

/* Modale Popup */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    width: 90%;
    max-width: 500px;
}

.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; }
.form-group input, .form-group textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.modal-buttons { display: flex; justify-content: center; gap: 15px; margin-top: 15px; }

/* ADAPTABILITATE EXCLUSIVĂ PE TELEFOANE (Max 600px) */
@media (max-width: 600px) {
    body {
        padding: 4px;
    }

    .container {
        height: calc(100vh - 8px);
        height: calc(100dvh - 8px);
        padding: 8px 10px 8px 10px;
    }

    .app-header h1 {
        font-size: 20px;
        margin-bottom: 2px;
    }

    /* Ascundem reclama pe mobil */
    .adsense-container {
        display: none !important;
    }

    .search-box {
        margin-bottom: 4px;
    }

    .search-box input {
        padding: 5px 30px 5px 10px;
        font-size: 13px;
    }

    .subject-item {
        padding: 6px 8px;
        font-size: 13px;
    }
}

/* Footer Copyright */
.app-footer {
    text-align: center;
    padding-top: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
    font-weight: 600;
    color: black;
}

/* Stil pentru modale mai mari (Batch) */
.modal-content.large-modal {
    max-width: 650px;
}

.modal-hint {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
}

#inputBatchText {
    font-family: monospace;
    font-size: 13px;
    resize: vertical;
}