/* ============================================================
   PhotoRenamer Admin â ŃŃĐ¸ĐťĐ¸
   Đ˘ŃĐźĐ˝Đ°Ń ŃĐľĐźĐ° Đ˛ ŃŃĐ¸ĐťĐľ Photoshop
   ============================================================ */

:root {
    /* ĐĐ°ĐťĐ¸ŃŃĐ° â ĐşĐ°Đş Đ˛ ĐşĐťĐ¸ĐľĐ˝ŃĐľ */
    --bg:            #2b2b2b;
    --panel:         #323232;
    --panel-dark:    #252525;
    --border:        #1e1e1e;
    --border-light:  #3a3a3a;

    --text:          #f0f0f0;
    --text-dim:      #999999;
    --text-muted:    #666666;

    --accent:        #1473e6;
    --accent-hover:  #2b8aff;
    --accent-press:  #0f5bbf;

    --btn:           #3a3a3a;
    --btn-hover:     #4a4a4a;

    --green:         #27ae60;
    --red:           #e74c3c;
    --orange:        #f39c12;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", "San Francisco", -apple-system, Roboto, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================================
   Đ˘Đ â22: ŃĐşŃĐ°Đ˝ ĐťĐžĐłĐ¸Đ˝Đ°
   ============================================================ */
#login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 20px;
}

.login-card label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.login-card input[type="password"] {
    width: 100%;
    background: var(--panel-dark);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
}

.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

.login-error {
    margin-top: 12px;
    padding: 10px;
    border-radius: 4px;
    font-size: 13px;
    display: none;
}

.login-error.active {
    display: block;
    background: rgba(231, 76, 60, 0.15);
    color: var(--red);
}

/* ============================================================
   Đ¨Đ°ĐżĐşĐ°
   ============================================================ */
.header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header h1::before {
    content: "đŚ";
    font-size: 20px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ============================================================
   ĐĐ˝ĐžĐżĐşĐ¸
   ============================================================ */
.btn {
    background: var(--btn);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.btn:hover {
    background: var(--btn-hover);
    border-color: var(--accent);
}

.btn:active {
    background: var(--panel-dark);
}

.btn:disabled {
    background: var(--panel);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
    font-weight: 600;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
    font-weight: 600;
}

.btn-success:hover {
    background: #229954;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ============================================================
   ĐĐşĐťĐ°Đ´ĐşĐ¸
   ============================================================ */
.tabs {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    gap: 4px;
}

.tab {
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-bottom: 3px solid transparent;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.tab-icon {
    font-size: 16px;
}

/* ============================================================
   ĐĐžĐ˝ŃĐľĐ˝Ń
   ============================================================ */
.content {
    padding: 24px;
    max-width: 95vw;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================================
   ĐĄŃĐ°ŃĐ¸ŃŃĐ¸ĐşĐ°
   ============================================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 16px 20px;
}

.stat-card .label {
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-card .value {
    color: var(--text);
    font-size: 28px;
    font-weight: 700;
}

.stat-card.new .value {
    color: var(--orange);
}

.stat-card.downloaded .value {
    color: var(--green);
}

/* ============================================================
   ĐĐ°Đ˝ĐľĐťŃ ŃĐżŃĐ°Đ˛ĐťĐľĐ˝Đ¸Ń (ŃĐ¸ĐťŃŃŃŃ, ĐżĐžĐ¸ŃĐş)
   ============================================================ */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-search {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    position: relative;
}

.toolbar-search input {
    width: 100%;
    background: var(--panel-dark);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px 12px 8px 36px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.toolbar-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.toolbar-search::before {
    content: "đ";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.5;
}

.toolbar-filters {
    display: flex;
    gap: 4px;
    background: var(--panel-dark);
    padding: 3px;
    border-radius: 4px;
}

.toolbar-filters .filter {
    background: transparent;
    color: var(--text-dim);
    border: none;
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s;
}

.toolbar-filters .filter:hover {
    color: var(--text);
}

.toolbar-filters .filter.active {
    background: var(--accent);
    color: #fff;
}

/* ============================================================
   Đ˘Đ°ĐąĐťĐ¸ŃŃ
   ============================================================ */
.table-wrapper {
    background: var(--panel);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    overflow: hidden;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: var(--panel-dark);
}

thead th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

tbody tr.new-row {
    background: rgba(243, 156, 18, 0.08);
}

tbody tr.new-row:hover {
    background: rgba(243, 156, 18, 0.12);
}

/* ============================================================
   ĐĄŃĐ°ŃŃŃŃ
   ============================================================ */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-new {
    background: rgba(243, 156, 18, 0.15);
    color: var(--orange);
}

.status-downloaded {
    background: rgba(39, 174, 96, 0.15);
    color: var(--green);
}

.status-bound {
    background: rgba(39, 174, 96, 0.15);
    color: var(--green);
}

.status-unbound {
    background: rgba(153, 153, 153, 0.15);
    color: var(--text-dim);
}

/* ============================================================
   Toast-ŃĐ˛ĐľĐ´ĐžĐźĐťĐľĐ˝Đ¸Ń
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    padding: 12px 18px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    font-size: 13px;
    min-width: 260px;
    max-width: 400px;
    animation: toast-in 0.3s ease;
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--green);
}

.toast.error {
    border-left-color: var(--red);
}

.toast.warning {
    border-left-color: var(--orange);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================
   ĐĐžĐ´Đ°ĐťŃĐ˝ŃĐľ ĐžĐşĐ˝Đ°
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in 0.2s;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--panel);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: modal-in 0.2s;
}

.modal h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================
   ĐŃŃŃĐžĐľ ŃĐžŃŃĐžŃĐ˝Đ¸Đľ
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state-text {
    font-size: 13px;
}

/* ============================================================
   ĐĐ°ĐłŃŃĐˇĐşĐ°
   ============================================================ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   ĐĐ˛ŃĐžĐžĐąĐ˝ĐžĐ˛ĐťĐľĐ˝Đ¸Đľ
   ============================================================ */
.auto-update {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================================
   ĐĐ´Đ°ĐżŃĐ¸Đ˛
   ============================================================ */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }

    .header-actions {
        flex-wrap: wrap;
    }

    .tabs {
        padding: 0 16px;
        overflow-x: auto;
    }

    .tab {
        padding: 12px 14px;
        white-space: nowrap;
    }

    .content {
        padding: 16px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .modal {
        min-width: auto;
        margin: 16px;
    }

    #toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* S.3: ĐżĐžĐ´ŃĐ˛ĐľŃĐşĐ° ŃŃŃĐžĐş Đ˛ ÂŤĐĐťĐ¸ĐľĐ˝ŃĐ°ŃÂť. */
tr.row-trusted  {
    background-color: rgba(39, 174, 96, 0.15);   /* ĐˇĐľĐťĐľĐ˝ĐžĐ˛Đ°ŃŃĐš */
}
tr.row-negative  {
    background-color: rgba(231, 76, 60, 0.15);    /* ĐşŃĐ°ŃĐ˝ĐžĐ˛Đ°ŃŃĐš */
}


/* ĐĐłŃĐ°Đ˝Đ¸ŃĐľĐ˝Đ¸Đľ ŃĐ¸ŃĐ¸Đ˝Ń Đ´ĐťŃ ĐşĐžĐťĐžĐ˝ĐşĐ¸ Ń ĐşĐžĐźĐżŃŃŃĐľŃĐ°ĐźĐ¸ */
#clients-tbody td:nth-child(9) {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

/* Đ˘Đ â25: ĐşĐžĐźĐżĐ°ĐşŃĐ˝Đ°Ń ŃĐ°ĐąĐťĐ¸ŃĐ° ĐşĐťĐ¸ĐľĐ˝ŃĐžĐ˛ */
#clients-tbody {
    font-size: 12px;
}

#clients-tbody td {
    padding: 8px 10px;
}

#clients-tbody th {
    font-size: 10px;
    padding: 8px 10px;
}

#clients-tbody td:nth-child(1) {
    max-width: 100px;
    word-break: break-word;
}

#clients-tbody td:nth-child(9) {
    max-width: 160px;
}


/* ТЗ-40: полупрозрачные иконки в таблице клиентов. */
.btn-icon {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dim);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    display: inline-block;
    line-height: 1.2;
}
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text);
}
.btn-icon-x {
    background: transparent;
    color: rgba(231, 76, 60, 0.7);
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 0 4px;
    transition: color 0.15s;
    font-family: inherit;
    display: inline-block;
    line-height: 1;
}
.btn-icon-x:hover {
    color: var(--red);
}

/* ТЗ-40-фикс-2: крупная контрастная иконка корзины (колонка «Удалить»). */
.btn-icon-trash {
    background: transparent;
    color: rgba(231, 76, 60, 0.7);
    border: none;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, transform 0.15s;
}
.btn-icon-trash:hover {
    color: var(--red);
    transform: scale(1.1);
}

/* ТЗ-40-фикс: кнопка «+» (пополнить баланс) — зелёный плюс на
   полупрозрачном зелёном фоне, как status-bound в «Привязан». */
.btn-add-deposit {
    background: rgba(39, 174, 96, 0.15);
    color: var(--green);
    border: 1px solid rgba(39, 174, 96, 0.3);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    min-width: 32px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
}
.btn-add-deposit:hover {
    background: rgba(39, 174, 96, 0.3);
    color: #fff;
    border-color: var(--green);
}
