﻿/* Chart of Accounts - Clean White Design */

:root {
    --primary: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-700: #374151;
    --gray-900: #111827;
}

.clean-page {
    background: #f9fafb;
    min-height: 100vh;
    font-size: 14px;
}

.clean-header {
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
}

.clean-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.clean-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.search-filters-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(249,250,251,0.98);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-300);
}

.form-control, .form-select {
    border: 1px solid var(--gray-300);
    font-size: 0.875rem;
    padding: 0.375rem 0.625rem;
}

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

.table-headers-sticky {
    position: relative;
}

.table-headers-sticky thead {
    position: sticky;
    top: 0;
    z-index: 100;
}

.table-headers-sticky thead th {
    position: sticky;
    top: 0;
    background: #ffffff !important;
    color: #374151 !important;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 1rem 0.875rem;
    border-bottom: 2px solid #e5e7eb !important;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
}

.table-body-scrollable {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.clean-table td {
    padding: 0.875rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
    font-weight: 400;
}

.account-row-level-0,
.account-row-level-1,
.account-row-level-2,
.account-row-level-default {
    background: white !important;
}

.account-row-level-0:hover,
.account-row-level-1:hover,
.account-row-level-2:hover,
.account-row-level-default:hover {
    background: #f9f9f9 !important;
}

.account-code,
.account-name-primary,
.account-name-secondary {
    font-weight: 400;
    color: var(--gray-900);
    font-size: 0.875rem;
}

/* ========== Clean Button Styles (Reusable) ========== */

.btn-clean {
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-clean:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    color: white;
}

.btn-clean:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Primary Button - أزرق بنفسجي متدرج */
.btn-clean-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-clean-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a4293 100%);
    color: white;
}

/* Secondary Button - وردي أحمر متدرج */
.btn-clean-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-clean-secondary:hover {
    background: linear-gradient(135deg, #e070e8 0%, #e23456 100%);
    color: white;
}

/* Success Button - أخضر متدرج */
.btn-clean-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.btn-clean-success:hover {
    background: linear-gradient(135deg, #0a8076 0%, #2dd165 100%);
    color: white;
}

/* Info Button - أزرق سماوي متدرج */
.btn-clean-info {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
}

.btn-clean-info:hover {
    background: linear-gradient(135deg, #00b8e6 0%, #2d64b8 100%);
    color: white;
}

/* Warning Button - برتقالي أصفر متدرج */
.btn-clean-warning {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
    color: #333;
}

.btn-clean-warning:hover {
    background: linear-gradient(135deg, #e08840 0%, #e0b840 100%);
    color: #333;
}

/* Danger Button - أحمر متدرج */
.btn-clean-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
}

.btn-clean-danger:hover {
    background: linear-gradient(135deg, #ff5252 0%, #dd4655 100%);
    color: white;
}

/* ========== Button Group Styles ========== */
.btn-group-clean {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Button with Icon */
.btn-clean i {
    font-size: 1rem;
}

/* Small Button Variant */
.btn-clean.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Large Button Variant */
.btn-clean.btn-lg {
    padding: 0.8rem 1.6rem;
    font-size: 1.05rem;
}

/* Full Width Button */
.btn-clean.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Loading State */
.btn-clean:disabled,
.btn-clean.loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .btn-clean {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .btn-group-clean {
        gap: 0.5rem;
    }

    .btn-clean.btn-block {
        width: 100%;
    }
}

.btn-action {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

.btn-action.btn-add {
    color: var(--success);
    border: 1px solid var(--success);
}

.btn-action.btn-edit {
    color: var(--warning);
    border: 1px solid var(--warning);
}

.btn-action.btn-delete {
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-action.btn-delete:disabled {
    background: var(--gray-100);
    color: var(--gray-400);
    opacity: 0.6;
}

.loading-container {
    padding: 4rem 2rem;
    text-align: center;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* ========== Tree View Styles ========== */

.tree-controls {
    display: inline-flex;
    gap: 0.25rem;
}

.tree-controls .btn-clean {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-clean-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.btn-clean-secondary:hover {
    box-shadow: 0 6px 16px rgba(100, 116, 139, 0.45);
}

.tree-toggle-cell {
    display: flex !important;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.5rem !important;
}

.btn-tree-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    color: var(--gray-700);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
}

.btn-tree-toggle:hover {
    background: var(--gray-200);
    color: #157A5B;
}

.btn-tree-toggle i {
    transition: transform 0.2s ease;
}

.tree-leaf-spacer {
    display: inline-block;
    width: 24px;
}

.tree-icon {
    font-size: 1.1em;
}

/* تمييز الحسابات الرئيسية (Level 0) */
.account-row-level-0 {
    background: #F9F8F4 !important;
    font-weight: 600;
}

.account-row-level-0 td {
    border-bottom: 1px solid #E6E2D9 !important;
}

.account-row-level-0 .account-name-primary {
    font-weight: 700;
    color: #1C2530;
}

/* تمييز الحسابات الفرعية (Level 1) */
.account-row-level-1 {
    background: #fefefe !important;
}

.account-row-level-1 .account-name-primary {
    font-weight: 600;
    color: var(--gray-900);
}

/* تمييز الحسابات الأعمق */
.account-row-level-2,
.account-row-level-default {
    background: white !important;
}

/* تأثير عند وجود أبناء */
.has-children {
    cursor: default;
}

.has-children .btn-tree-toggle {
    visibility: visible;
}

/* تأثير الحساب المطوي */
.is-collapsed .btn-tree-toggle i {
    transform: rotate(0deg);
}

/* تنسيق خاص للاسم حسب المستوى مع إزاحة */
.account-row-level-0 .account-name-primary {
    padding-right: 0 !important;
}

.account-row-level-1 .account-name-primary {
    padding-right: 20px !important;
}

.account-row-level-2 .account-name-primary {
    padding-right: 40px !important;
}

.account-row-level-default .account-name-primary {
    padding-right: 60px !important;
}

/* خط عمودي للفروع */
.account-row-level-1 td:first-child,
.account-row-level-2 td:first-child,
.account-row-level-default td:first-child {
    position: relative;
}

.account-row-level-1 td:first-child::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 0;
    bottom: 50%;
    width: 2px;
    background: var(--gray-300);
}

.account-row-level-2 td:first-child::before,
.account-row-level-default td:first-child::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 0;
    height: 100%;
    width: 2px;
    background: var(--gray-200);
}

/* ==================== Bulk Update Bar ==================== */
.bulk-update-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: #E8F3ED;
    border-radius: 8px;
    margin-top: 0.75rem;
    border: 1px solid #C7E3D6;
}

.bulk-select-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.bulk-select-all .form-check-input {
    width: 1.1rem;
    height: 1.1rem;
}

.bulk-field-selector,
.bulk-value-input {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bulk-field-selector label,
.bulk-value-input label {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-weight: 500;
}

.bulk-field-selector select,
.bulk-value-input select,
.bulk-value-input input {
    min-width: 180px;
    border-radius: 0.375rem;
    border: 1px solid var(--gray-300);
}

.bulk-update-bar .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
    margin-right: auto;
}

/* Selected row highlight */
.row-selected {
    background-color: #E8F3ED !important;
}

.row-selected:hover {
    background-color: #DAEEE4 !important;
}
