/* ========================================
   Odoo Image Uploader - Stylesheet
   ======================================== */

/* ========== VARIABLES ========== */
:root {
    --primary: #714B67;
    --primary-dark: #5a3c53;
    --primary-light: #8e6585;
    --accent: #00A09D;
    --accent-dark: #008785;
    --gold: #FFD700;
    --silver: #C0C0C0;
    --bronze: #CD7F32;
    --bg: #f4f1f3;
    --card: #ffffff;
    --text: #2c2c2c;
    --text-light: #777;
    --border: #e0d8de;
    --danger: #e74c3c;
    --success: #27ae60;
    --shadow: 0 2px 16px rgba(113, 75, 103, 0.10);
}

/* ========== RESET ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent-dark);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ========== INPUTS ========== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color .2s;
    background: #fff;
    font-family: inherit;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

/* ========== SCREENS ========== */
.screen {
    display: none;
}

.screen.active {
    display: flex;
}

/* ========================================
   LOGIN SCREEN
   ======================================== */
#loginScreen {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 40px 36px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .18);
}

.login-card h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 26px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 28px;
    font-size: 14px;
}

.login-card .logo-icon {
    text-align: center;
    font-size: 48px;
    margin-bottom: 12px;
}

/* Tab Switch (Login / Register) */
.tab-switch {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
    border: 2px solid var(--primary);
}

.tab-switch button {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--primary);
    transition: all .2s;
}

.tab-switch button.active {
    background: var(--primary);
    color: #fff;
}

.login-error {
    background: #fdeaea;
    color: var(--danger);
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
    text-align: center;
}

/* ========================================
   NAVBAR
   ======================================== */
.navbar {
    background: var(--primary);
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .brand {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar .nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar .nav-btn {
    background: rgba(255, 255, 255, .15);
    border: none;
    color: #fff;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    transition: background .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar .nav-btn:hover {
    background: rgba(255, 255, 255, .25);
}

.user-badge {
    background: rgba(255, 255, 255, .2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.upload-counter {
    background: var(--accent);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
#mainScreen {
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 24px auto;
    padding: 0 16px;
}

/* ========== SEARCH ========== */
.search-box {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.search-box h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--primary);
}

.search-row {
    display: flex;
    gap: 12px;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper input {
    padding-left: 40px;
}

.search-clear-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--border);
    border: none;
    color: var(--text-light);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 13px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    line-height: 1;
}

.search-clear-btn:hover {
    background: var(--danger);
    color: #fff;
}

.search-clear-btn.visible {
    display: flex;
}

.search-row .btn {
    white-space: nowrap;
}

/* ========== SEARCH RESULTS ========== */
.results-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-card {
    background: var(--card);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all .2s;
    border: 2px solid transparent;
}

.product-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.product-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background: #f0ecee;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-thumb .no-img {
    font-size: 28px;
    opacity: .4;
}

.product-info {
    flex: 1;
}

.product-info .p-name {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 4px;
}

.product-info .p-barcode {
    font-size: 13px;
    color: var(--text-light);
}

.product-info .p-id {
    font-size: 12px;
    color: var(--text-light);
}

.product-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.product-status.has-img {
    background: #e8f8ef;
    color: var(--success);
}

.product-status.no-img {
    background: #fdeaea;
    color: var(--danger);
}

/* ========== LOADING & NO RESULTS ========== */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.loading-spinner .spin {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 15px;
}

/* ========================================
   PRODUCT DETAIL / UPLOAD
   ======================================== */
.product-detail {
    background: var(--card);
    border-radius: 12px;
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.product-detail .back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-img {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    background: #f0ecee;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.detail-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-img .no-img {
    font-size: 48px;
    opacity: .3;
}

.detail-info .d-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.detail-info .d-meta {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.8;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #faf8f9;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #f5f0f3;
}

.upload-zone .uz-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.upload-zone .uz-text {
    font-size: 15px;
    color: var(--text-light);
}

/* Upload Progress */
.upload-progress {
    display: none;
    text-align: center;
    padding: 20px;
}

.upload-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}

.upload-progress .progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width .3s;
    width: 0%;
}

/* Upload Success */
.upload-success {
    display: none;
    text-align: center;
    padding: 20px;
    color: var(--success);
}

.upload-success .check-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

/* ========================================
   MODALS (Shared)
   ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .25);
}

.modal h2 {
    margin-bottom: 16px;
    color: var(--primary);
    font-size: 18px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* ========== CROPPER MODAL ========== */
.cropper-container-wrapper {
    max-height: 400px;
    overflow: hidden;
    border-radius: 8px;
    background: #eee;
}

#cropImage {
    display: block;
    max-width: 100%;
}

.quality-warning {
    display: none;
    background: #fff8e1;
    color: #e65100;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 12px;
}

/* ========================================
   LEADERBOARD
   ======================================== */
.leaderboard-list {
    list-style: none;
}

.leaderboard-list li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: #faf8f9;
    transition: all .2s;
}

.leaderboard-list li.rank-1 {
    background: linear-gradient(135deg, #fff9e6, #fff3cc);
    border: 2px solid var(--gold);
}

.leaderboard-list li.rank-2 {
    background: linear-gradient(135deg, #f7f7f7, #eeeeee);
    border: 2px solid var(--silver);
}

.leaderboard-list li.rank-3 {
    background: linear-gradient(135deg, #fdf2e6, #fbe8d2);
    border: 2px solid var(--bronze);
}

.lb-rank {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.rank-1 .lb-rank {
    background: var(--gold);
    color: #fff;
}

.rank-2 .lb-rank {
    background: var(--silver);
    color: #fff;
}

.rank-3 .lb-rank {
    background: var(--bronze);
    color: #fff;
}

.lb-rank-default {
    background: var(--border);
    color: var(--text-light);
}

.lb-info {
    flex: 1;
}

.lb-name {
    font-weight: 700;
    font-size: 15px;
}

.lb-stats {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.lb-count {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
}

.lb-medal {
    font-size: 22px;
}

.leaderboard-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
}

/* ========================================
   CATEGORIES - التصنيفات
   ======================================== */

/* --- Product Category Section (inside detail) --- */
.product-categ-section {
    background: #faf8f9;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.product-categ-section h3 {
    font-size: 15px;
    color: var(--primary);
    margin-bottom: 10px;
}

.categ-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.categ-tag {
    background: var(--primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.categ-remove {
    background: rgba(255, 255, 255, .3);
    border: none;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.categ-remove:hover {
    background: rgba(255, 255, 255, .5);
}

.categ-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.categ-select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    font-family: inherit;
    min-width: 180px;
}

.categ-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* --- Categories Modal --- */
.categ-add-form {
    background: #f5f0f3;
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.categ-tree {
    max-height: 400px;
    overflow-y: auto;
}

.categ-tree-item {
    margin-bottom: 4px;
}

.categ-tree-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 8px;
    transition: background .2s;
}

.categ-tree-row:hover {
    background: #f5f0f3;
}

.categ-parent > .categ-tree-row {
    font-weight: 700;
    font-size: 15px;
}

.categ-tree-name {
    flex: 1;
}

.categ-tree-actions {
    display: flex;
    gap: 6px;
}

.categ-tree-children {
    padding-right: 24px;
    border-right: 2px solid var(--border);
    margin-right: 12px;
}

.categ-child .categ-tree-row {
    font-size: 14px;
    color: var(--text-light);
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    animation: toastIn .3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   SCORE BADGE
   ======================================== */
.score-earned {
    background: linear-gradient(135deg, #fff9e6, #fff3cc);
    border: 2px solid var(--gold);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    margin-top: 10px;
    display: inline-block;
}

.lb-details {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 1px;
}

/* ========================================
   ADMIN PANEL
   ======================================== */
.nav-btn-admin {
    background: rgba(255, 200, 0, .25) !important;
}

.admin-tabs {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    border: 2px solid var(--primary);
}

.admin-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--primary);
    transition: all .2s;
}

.admin-tab.active {
    background: var(--primary);
    color: #fff;
}

.admin-panel {
    min-height: 150px;
}

.admin-user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: #faf8f9;
    transition: background .2s;
}

.admin-user-row:hover {
    background: #f5f0f3;
}

.admin-user-info {
    flex: 1;
}

.admin-user-name {
    font-weight: 700;
    font-size: 14px;
}

.admin-user-email {
    font-size: 12px;
    color: var(--text-light);
}

.admin-user-stats {
    font-size: 12px;
    color: var(--text-light);
}

.admin-user-actions {
    display: flex;
    gap: 6px;
}

.admin-badge {
    background: var(--gold);
    color: #333;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.admin-badge-disabled {
    background: var(--danger);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.admin-setting-group {
    background: #faf8f9;
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.admin-setting-group h3 {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 10px;
}

.admin-activity-row {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 4px;
    background: #faf8f9;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-activity-action {
    font-weight: 600;
}

.admin-activity-time {
    font-size: 11px;
    color: var(--text-light);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 600px) {
    .login-card {
        padding: 28px 20px;
    }

    .search-row {
        flex-direction: column;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .navbar {
        padding: 0 12px;
    }

    .navbar .brand span {
        display: none;
    }

    .modal {
        padding: 20px;
    }
}
