/* Organization Chart Styles */

.orgchart-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
    overflow-x: auto;
}

.orgchart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.orgchart-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.orgchart-controls {
    display: flex;
    gap: 10px;
}

.orgchart {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 800px;
    padding: 20px;
}

/* Organization Level */
.org-node {
    background: linear-gradient(135deg, var(--gold-color), #f59e0b);
    color: var(--dark-bg);
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
    margin-bottom: 40px;
    text-align: center;
    min-width: 300px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.org-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(251, 191, 36, 0.4);
}

.org-node.editable:hover {
    border: 2px solid var(--primary-color);
}

.org-node h4 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 5px;
}

.org-node .org-code {
    font-size: 12px;
    opacity: 0.8;
    text-transform: uppercase;
}

.org-node .edit-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s;
}

.org-node.editable:hover .edit-icon {
    opacity: 1;
}

/* Master Admin Level */
.master-admin-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    position: relative;
}

.master-admin-container::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: var(--border-color);
}

.user-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 200px;
    text-align: center;
    position: relative;
    cursor: move;
    transition: all 0.3s;
}

.user-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.user-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.user-card.drag-over {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.user-card.master-admin {
    border-color: var(--gold-color);
    background: linear-gradient(to bottom, #fffbeb, white);
}

.user-card.master-adjunct {
    border-color: #f59e0b;
    background: linear-gradient(to bottom, #fef3c7, white);
}

.user-card.branch-admin {
    border-color: var(--primary-color);
    background: linear-gradient(to bottom, #eff6ff, white);
}

.user-card.branch-adjunct {
    border-color: #7c3aed;
    background: linear-gradient(to bottom, #f5f3ff, white);
}

.user-card .user-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.user-card .user-role {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.user-card .user-email {
    font-size: 10px;
    color: var(--text-secondary);
    word-break: break-all;
}

.user-card .user-id {
    font-size: 9px;
    color: var(--primary-color);
    font-family: monospace;
    margin: 3px 0;
    font-weight: 600;
}

.user-card .role-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.btn-role-action {
    padding: 4px 10px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    transition: all 0.3s;
    width: 100%;
}

.btn-role-action:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.user-card .drag-handle {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s;
}

.user-card:hover .drag-handle {
    opacity: 1;
}

.user-card.not-draggable {
    cursor: default;
}

.user-card.not-draggable .drag-handle {
    display: none;
}

/* Branches Container */
.branches-container {
    display: flex;
    gap: 40px;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
}

.branches-container::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: var(--border-color);
}

/* Branch Node */
.branch-node {
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 20px;
    min-width: 280px;
    position: relative;
}

.branch-node.drop-zone {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.branch-users.drag-over {
    border: 2px dashed var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
}

.branch-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.branch-header:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.branch-header.editable:hover {
    border: 2px solid white;
}

.branch-header h5 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 3px;
}

.branch-header .branch-code {
    font-size: 11px;
    opacity: 0.9;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    max-width: 100%;
}

.branch-header .edit-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
}

.branch-header.editable:hover .edit-icon {
    opacity: 1;
}

.branch-users {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 100px;
}

.branch-users.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

/* Edit Modal */
.edit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

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

.edit-modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.edit-modal-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

.edit-modal-content .form-group {
    margin-bottom: 20px;
}

.edit-modal-content .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* Permission Indicator */
.permission-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 10px;
}

.permission-badge.can-edit {
    background: #d1fae5;
    color: #065f46;
}

.permission-badge.view-only {
    background: #f3f4f6;
    color: #6b7280;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    gap: 5px;
}

.zoom-controls button {
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.zoom-controls button:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .branches-container {
        flex-direction: column;
        align-items: center;
    }
    
    .master-admin-container {
        flex-direction: column;
        align-items: center;
    }
    
    .orgchart {
        min-width: 100%;
    }
}

/* Loading State */
.orgchart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    font-size: 18px;
    color: var(--text-secondary);
}

/* Success Message */
.save-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    z-index: 3000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Error Message */
.save-error {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--danger-color);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    z-index: 3000;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

/* Error message in modal */
.error-message {
    color: var(--danger-color);
    margin-top: 10px;
    padding: 10px;
    background: #fee2e2;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
}

.error-message.hidden {
    display: none;
}