/* ============================================
   استایل اصلی افزونه تحلیل‌گر حرفه‌ای
   ============================================ */

:root {
    --primary: #2c3e50;
    --primary-light: #34495e;
    --secondary: #3498db;
    --secondary-dark: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --bg: #ecf0f1;
    --card-bg: #ffffff;
    --border: #bdc3c7;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 8px;
    --transition: all 0.3s ease;
}

/* ===== محفظه اصلی ===== */
.frame-analyzer-pro {
    max-width: 1400px;
    margin: 20px auto;
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
}

/* ===== هدر ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: bold;
}

.app-logo i {
    font-size: 28px;
    color: var(--secondary);
}

.app-version {
    font-size: 12px;
    opacity: 0.7;
    background: rgba(255,255,255,0.15);
    padding: 4px 12px;
    border-radius: 20px;
}

/* ===== نوار ابزار ===== */
.app-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    gap: 2px;
}

.toolbar-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
    margin: 0 8px;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    font-size: 16px;
    transition: var(--transition);
}

.tool-btn:hover {
    background: var(--bg);
    transform: translateY(-1px);
}

.tool-btn.active {
    background: var(--secondary);
    color: white;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.tool-btn.btn-analyze {
    background: var(--success);
    color: white;
    padding: 0 20px;
    width: auto;
    gap: 8px;
    font-weight: bold;
}

.tool-btn.btn-analyze:hover {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

/* ===== پنل اصلی ===== */
.app-main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    height: calc(100vh - 160px);
    min-height: 600px;
}

/* ===== ستون چپ: Canvas ===== */
.app-canvas-container {
    position: relative;
    background: #fafafa;
    overflow: hidden;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

#frame-canvas-pro {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}

/* ===== Overlay راهنما ===== */
.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.canvas-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: white;
    max-width: 400px;
}

.overlay-content i {
    font-size: 56px;
    color: var(--secondary);
    margin-bottom: 16px;
}

.overlay-content h3 {
    font-size: 24px;
    margin-bottom: 8px;
}

.overlay-content p {
    opacity: 0.8;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ===== مختصات ماوس ===== */
.canvas-coords {
    position: absolute;
    bottom: 12px;
    right: 16px;
    background: rgba(44, 62, 80, 0.85);
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 5;
}

.canvas-coords span {
    color: var(--secondary);
    font-weight: bold;
}

/* ===== نوار وضعیت ===== */
.canvas-status {
    display: flex;
    gap: 20px;
    padding: 6px 16px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-light);
}

.canvas-status strong {
    color: var(--text);
}

/* ===== ستون راست: پنل ویژگی‌ها ===== */
.app-properties {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    height: 100%;
    overflow: hidden;
}

/* ===== تب‌ها ===== */
.properties-tabs {
    display: flex;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
}

.prop-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-light);
    transition: var(--transition);
    white-space: nowrap;
}

.prop-tab:hover {
    color: var(--text);
    background: rgba(0,0,0,0.05);
}

.prop-tab.active {
    color: var(--secondary);
    border-bottom-color: var(--secondary);
    background: white;
}

.prop-tab i {
    font-size: 14px;
}

/* ===== محتوای تب‌ها ===== */
.properties-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.prop-panel {
    display: none;
    padding: 16px;
    height: 100%;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.prop-panel.active {
    display: block;
}

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

/* ===== بخش‌های پنل ===== */
.panel-section {
    margin-bottom: 20px;
}

.panel-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bg);
}

.panel-section h4 i {
    color: var(--secondary);
    font-size: 16px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-header h4 {
    font-size: 14px;
    color: var(--text);
    margin: 0;
}

/* ===== تنظیمات ===== */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    cursor: pointer;
}

.setting-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--secondary);
    cursor: pointer;
}

.toggle-label {
    user-select: none;
}

.form-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    flex: 1;
}

.form-range {
    flex: 1;
    accent-color: var(--secondary);
}

/* ===== جداول ===== */
.panel-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 400px;
}

.prop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.prop-table thead {
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 2;
}

.prop-table th {
    padding: 8px 6px;
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}

.prop-table td {
    padding: 4px 6px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.prop-table input,
.prop-table select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 12px;
    background: transparent;
    transition: var(--transition);
}

.prop-table input:hover,
.prop-table select:hover {
    background: var(--bg);
}

.prop-table input:focus,
.prop-table select:focus {
    border-color: var(--secondary);
    background: white;
    outline: none;
}

.prop-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--secondary);
    cursor: pointer;
}

.prop-table .btn-del-row {
    color: var(--danger);
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.prop-table .btn-del-row:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ===== دکمه‌ها ===== */
.btn-sm {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-add {
    background: var(--secondary);
    color: white;
}

.btn-add:hover {
    background: var(--secondary-dark);
    transform: translateY(-1px);
}

.btn-primary {
    padding: 10px 24px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--secondary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    padding: 10px 24px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: #d5d8dc;
}

/* ===== وضعیت خالی ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state i {
    margin-bottom: 16px;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ===== مودال ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ===== پاسخگویی ===== */
@media (max-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr 340px;
    }
}

@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        height: auto;
        min-height: 800px;
    }
    
    .app-canvas-container {
        min-height: 400px;
    }
    
    .app-properties {
        height: 400px;
        border-right: none;
        border-top: 1px solid var(--border);
    }
    
    .app-toolbar {
        gap: 2px;
        padding: 6px 8px;
    }
    
    .tool-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .tool-btn.btn-analyze {
        padding: 0 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 8px 16px;
    }
    
    .app-logo {
        font-size: 16px;
    }
    
    .app-logo i {
        font-size: 20px;
    }
    
    .properties-tabs {
        overflow-x: auto;
    }
    
    .prop-tab {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .prop-tab span {
        display: none;
    }
}

/* ===== اسکرول‌بار سفارشی ===== */
.prop-panel::-webkit-scrollbar,
.panel-table-wrap::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.prop-panel::-webkit-scrollbar-track,
.panel-table-wrap::-webkit-scrollbar-track {
    background: var(--bg);
}

.prop-panel::-webkit-scrollbar-thumb,
.panel-table-wrap::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.prop-panel::-webkit-scrollbar-thumb:hover,
.panel-table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}