@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Cairo', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #0366d6;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* Enhanced Tabs Styles */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.tab:hover {
    background: rgba(28, 110, 194, 0.1);
    color: #1b6ec2;
    transform: translateY(-1px);
}

.tab.active {
    background: #1b6ec2;
    color: white;
    box-shadow: 0 4px 12px rgba(28, 110, 194, 0.3);
    transform: translateY(-2px);
}

.tab.active::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1b6ec2;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Multi-select Organizations */
.organizations-selector {
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 16px;
    background: #f8f9fa;
    margin-bottom: 16px;
}

.organizations-selector h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.organizations-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.organization-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.organization-option:hover {
    background: rgba(28, 110, 194, 0.05);
    border-color: #1b6ec2;
    transform: translateX(4px);
}

.organization-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #1b6ec2;
    cursor: pointer;
}

.organization-option label {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.select-all-organizations {
    background: #1b6ec2;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
    align-self: flex-start;
}

.select-all-organizations:hover {
    background: #1861ac;
    transform: translateY(-1px);
}

.selected-organizations-count {
    background: #1b6ec2;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Document Types Management Styles */
.document-type-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #e9ecef;
}

.color-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    min-width: 60px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-input {
    width: 60px !important;
    height: 40px;
    padding: 0;
    border: none;
    cursor: pointer;
}

.category-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.category-badge.org {
    background-color: rgba(28, 110, 194, 0.1);
    color: #1b6ec2;
}

.category-badge.emp {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.status-badge.required {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.status-badge.optional {
    background-color: rgba(23, 162, 184, 0.1);
    color: #17a2b8;
}

.status-badge.active {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.status-badge.inactive {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Enhanced Modal Tab Styles */
.modal .tabs {
    background: linear-gradient(135deg, #f1f3f4 0%, #e8eaed 100%);
    border-radius: 8px 8px 0 0;
    padding: 6px;
    margin-bottom: 20px;
    border: 1px solid #dadce0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.modal .tab {
    padding: 12px 20px;
    font-size: 13px;
    margin: 0 2px;
    border-radius: 6px;
    min-height: 40px;
    font-weight: 600;
}

.modal .tab:hover {
    background: rgba(66, 133, 244, 0.08);
    color: #4285f4;
}

.modal .tab.active {
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.modal .tab.active::before {
    border-top-color: #4285f4;
}

.modal .tab-content {
    display: none;
    padding: 20px;
    background: #fafbfc;
    border-radius: 0 0 8px 8px;
    min-height: 350px;
    border: 1px solid #dadce0;
    border-top: none;
}

.modal .tab-content.active {
    display: block;
    animation: modalFadeIn 0.3s ease-in-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tab Content Sections */
.tab-section {
    margin-bottom: 25px;
}

.tab-section h4 {
    color: #333;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-section .material-icons {
    font-size: 20px;
    color: #4285f4;
}

/* Form Row in Tabs */
.tab-content .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.tab-content .form-row.single {
    grid-template-columns: 1fr;
}

.tab-content .form-group {
    margin-bottom: 16px;
}

.tab-content .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* Grid layout for forms (match reference proportions) */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 992px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

.tab-content .form-input,
.tab-content .form-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.tab-content .form-input:focus,
.tab-content .form-select:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

/* Modal Overlay Enhancement */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 9999 !important;
    backdrop-filter: blur(3px);
    animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(3px);
    }
}

.modal.large {
    width: 640px !important;
    max-width: 90vw !important;
    background: white !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    overflow: hidden !important;
    animation: slideInModal 0.25s ease-out;
    position: relative !important;
    display: block !important;
}

/* Match reference: modal form grid */
.modal .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

@keyframes slideInModal {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Compact modal variant for DocumentTypes */
.modal.modal-compact {
    width: 560px !important;
    max-width: 90vw !important;
    max-height: 85vh !important;
    background: #fff !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 48px rgba(0,0,0,0.28) !important;
    overflow: hidden !important;
    position: relative !important;
    display: block !important;
    /* prevent flex stretching inside overlay */
    flex: 0 0 auto !important;
    align-self: center !important;
    animation: slideInModal 0.25s ease-out;
}

/* Tighter content area to avoid inner overflow pushing modal size */
.modal.modal-compact .modal-content {
    max-height: calc(85vh - 140px);
    overflow-y: auto;
}

.modal-header {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
}

.modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-content {
    padding: 0;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
}

/* Responsive Tabs */
@media (max-width: 768px) {
    .tabs {
        flex-direction: column;
        padding: 8px;
    }

    .tab {
        margin: 2px 0;
        justify-content: flex-start;
        text-align: right;
    }

    .modal .tab-content {
        padding: 15px;
        min-height: 300px;
    }

    .tab-content .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .modal.large {
        width: 95%;
        max-height: 95vh;
        margin: 10px;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-title {
        font-size: 18px;
    }
}

/* Ensure modal appears above everything */
body.modal-open {
    overflow: hidden;
}

/* Removed problematic pointer-events rules that were blocking interactions */

/* Additional modal fixes */
.modal-overlay {
    font-family: 'Cairo', sans-serif;
}

.modal-overlay .modal {
    pointer-events: auto;
    margin: auto;
}

/* Fullscreen modal option (matches reference full-screen panel) */
.modal-overlay.fullscreen {
    align-items: stretch !important;
}

.modal.fullscreen {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
}

.modal.fullscreen .modal-content {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
}

/* Button styles */
.btn-info {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
    border-color: #117a8b;
    color: white;
}

/* Tabs Container - Match Reference Design */
.tabs-container {
    width: 100%;
}

.tabs-nav {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
    background: var(--background-secondary);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    padding: 16px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.tab-btn:hover {
    background: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.tab-btn .material-icons {
    font-size: 18px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Document Types Modal Styles */
.document-type-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.color-input {
    width: 60px !important;
    height: 40px;
    padding: 4px;
    border-radius: 8px;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.document-types-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.document-type-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.document-type-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.type-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.type-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.type-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.type-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.type-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.type-category {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--background-secondary);
    padding: 2px 8px;
    border-radius: 12px;
}

.type-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.type-status.required {
    background: #fee2e2;
    color: #dc2626;
}

.type-status.optional {
    background: #f0f9ff;
    color: #0369a1;
}

.type-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-error {
    background-color: #dc2626;
    border-color: #dc2626;
    color: white;
}

.btn-error:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
}
