/* style.css */

/* ================================================================== */
/* === GLOBAL STYLES                                              === */
/* ================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    padding: 20px;
    color: #333;
}

button {
    cursor: pointer;
    font-family: inherit;
}

a {
    text-decoration: none;
    color: #3498db;
}

a:hover {
    text-decoration: underline;
}

/* ================================================================== */
/* === AUTHENTICATION (Login / Register)                          === */
/* ================================================================== */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.auth-container h1 { color: #2c3e50; margin-bottom: 10px; }
.auth-container h2 { color: #34495e; margin-bottom: 20px; }
.slogan { font-style: italic; color: #777; margin-top: -5px; margin-bottom: 25px; }
.auth-switch { margin-top: 20px; }

/* Form Elements */
.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; color: #555; }

.form-group input, 
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group textarea { resize: vertical; }

button[type="submit"], 
.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
}

button[type="submit"]:hover,
.btn-primary:hover {
    background-color: #2980b9;
}

/* Alerts */
.error { color: #e74c3c; background-color: #fdd; padding: 10px; border-radius: 4px; margin-bottom: 15px; }
.success { color: #27ae60; background-color: #dfd; padding: 10px; border-radius: 4px; margin-bottom: 15px; }

/* Language Selector on Login */
.language-selector {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}
.language-selector select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
}

/* ================================================================== */
/* === DASHBOARD LAYOUT                                           === */
/* ================================================================== */
.dashboard-container {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.logout-link { display: block; text-align: center; margin-top: 30px; color: #3498db; }

/* Header Area */
header.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.header-primary-actions { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.header-primary-actions h1 { margin: 0; font-size: 1.8em; color: #2c3e50; }

.header-user-actions { display: flex; align-items: center; gap: 10px; }

.header-secondary-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; width: 100%; }

/* Notebook Selector Controls */
.notebook-selector-container { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.notebook-selector-container p { margin: 0; color: #777; }
.notebook-management-group { display: flex; align-items: center; gap: 10px; }

.notebook-selector-form select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    font-size: 1em;
}

/* Circular Header Buttons */
.header-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ecf0f1;
    color: #34495e;
    border: none;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    transition: background-color 0.2s;
}
.header-btn:hover { background-color: #bdc3c7; }

/* Special styling for the "Add Notebook" (+) button */
.add-notebook-btn { position: relative; overflow: visible; }
.add-notebook-btn::after {
    content: '+';
    position: absolute;
    top: 0; right: 0;
    background-color: #27ae60;
    color: white;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 1px solid white;
    display: flex; justify-content: center; align-items: center;
    font-size: 14px; font-weight: bold; line-height: 1;
}

/* ================================================================== */
/* === QR CODE DASHBOARD (Main Content)                           === */
/* ================================================================== */

/* Add Item Form */
.qr-add-form {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-bottom: 20px;
}
.qr-add-form button { width: auto; min-width: 150px; }

/* Item List */
.qrcode-item-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Individual Item Card */
.qrcode-item {
    display: flex;
    align-items: flex-start; /* Align to top */
    gap: 15px;
    padding: 15px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: box-shadow 0.2s;
}
.qrcode-item:hover { box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* Thumbnail */
.qr-item-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    background-color: #eee;
    flex-shrink: 0;
}

/* Item Content */
.qr-item-details { flex-grow: 1; min-width: 0; /* Prevents flex overflow */ }

.qr-item-title {
    font-weight: bold;
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

.qr-item-lang-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    background-color: #95a5a6;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
    line-height: 1.2;
}

.qr-item-description-preview {
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
    display: block;
}

/* Inline Editing Styles */
.edit-title-input { width: 100%; padding: 5px; margin-bottom: 5px; }
.edit-description-textarea { width: 100%; padding: 5px; resize: vertical; }

/* Item Actions (Buttons) */
.qr-item-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

.qr-default-actions, .qr-edit-actions {
    display: flex;
    gap: 5px;
}

.qr-item-actions button {
    padding: 5px 10px;
    font-size: 14px;
    background-color: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    color: #333;
}
.qr-item-actions button:hover { background-color: #bdc3c7; }

/* Specific Button Colors */
.delete-btn { background-color: #e74c3c !important; color: white !important; border-color: #c0392b !important; }
.delete-btn:hover { background-color: #c0392b !important; }
.btn-save { background-color: #27ae60 !important; color: white !important; }
.btn-cancel-edit { background-color: #95a5a6 !important; color: white !important; }

/* QR Code Display Section */
.qrcode-generation-section {
    margin-top: 30px;
    padding: 20px;
    text-align: center;
    background-color: #f4f7f6;
    border-radius: 8px;
    border: 1px dashed #ccc;
}
#qrcode-display {
    margin: 20px auto 0;
    display: flex;
    justify-content: center;
    padding: 10px;
    background-color: white;
    width: fit-content;
    border: 1px solid #ccc;
}

/* ================================================================== */
/* === MANAGE NOTEBOOKS PAGE                                      === */
/* ================================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.page-header-actions .btn-primary { width: auto; padding: 10px 20px; }
.back-link { display: inline-block; margin-top: 10px; color: #3498db; }

.notebook-list { margin-top: 20px; }
.notebook-item-container { border-bottom: 1px solid #eee; padding: 10px 0; }
.notebook-item-container:last-child { border-bottom: none; }

.notebook-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; }
.notebook-name { font-weight: bold; font-size: 1.1em; }

.notebook-actions { display: flex; align-items: center; gap: 10px; }

/* Action Buttons (Icons) */
.action-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    color: white;
    border: none;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s;
}
.action-btn:hover { opacity: 0.9; }

.action-btn.open { background-color: #27ae60; }
.action-btn.edit { background-color: #3498db; }
.action-btn.delete { background-color: #e74c3c; }

/* ================================================================== */
/* === PROFILE PAGE                                               === */
/* ================================================================== */
.profile-section { margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee; }
.profile-section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

.user-email-display {
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-family: monospace;
    color: #555;
}

.danger-zone {
    border: 1px solid #e74c3c;
    background-color: #fff5f5;
    padding: 20px;
    border-radius: 8px;
}
.danger-zone h2 { color: #c0392b; margin-top: 0; }
.btn-full-danger { background-color: #e74c3c; width: 100%; color: white; border: none; padding: 12px; border-radius: 4px; font-weight: bold; }
.btn-full-danger:hover { background-color: #c0392b; }

/* ================================================================== */
/* === MODALS                                                     === */
/* ================================================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px; right: 20px;
    cursor: pointer;
}
.close-btn:hover { color: black; }

/* ================================================================== */
/* === MOBILE RESPONSIVENESS                                      === */
/* ================================================================== */
@media (max-width: 768px) {
    body { padding: 0; }
    .dashboard-container { margin: 0; padding: 15px 10px; border-radius: 0; box-shadow: none; }
    
    .header-primary-actions h1 { font-size: 1.5em; }
    .header-secondary-controls { justify-content: center; }
    
    .notebook-selector-container {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        align-items: center;
    }
    
    .qrcode-item { flex-direction: column; align-items: flex-start; }
    .qr-item-thumb { width: 100%; height: 150px; }
    .qr-item-details { width: 100%; }
    .qr-item-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
}

/* ================================================================== */
/* === RTL SUPPORT (Arabic, etc.)                                 === */
/* ================================================================== */
[dir="rtl"] { direction: rtl; }
[dir="rtl"] .form-group { text-align: right; }
[dir="rtl"] .close-btn { float: left; right: auto; left: 20px; }
[dir="rtl"] .qr-item-lang-badge { margin-left: 0; margin-right: 8px; }

/* Auto-detect input direction */
[dir="auto"][style*="direction: rtl"],
[dir="auto"]:dir(rtl) { text-align: right; }