/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --light-color: #f8fafc;
    --dark-color: #1e293b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navigation */
.navbar {
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

.navbar .container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 2rem;
}

.navbar-brand {
    font-size: 1.75rem;
    font-weight: bold;
    text-decoration: none;
}

.navbar-brand:hover {
    text-decoration: none;
}

.brand-auto {
    color: #666;
    font-weight: 600;
}

.brand-cas {
    color: var(--primary-color);
    font-weight: 900;
}

.navbar-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.union-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.union-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 0.5rem 1.25rem;
    border-radius: 25px;
    font-size: 0.85rem;
    color: #333;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 600px;
}

.dropdown-toggle-small {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 15px;
    text-decoration: none;
    transition: all 0.3s;
}

.dropdown-toggle-small:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.union-display i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.separator {
    margin: 0 0.75rem;
    color: #ccc;
}

.accreditation-number {
    font-weight: 600;
    color: var(--primary-color);
}

/* Navbar Right Section */
.navbar-right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.nav-group {
    display: flex;
    gap: 0;
    background: #f8f9fa;
    border-radius: 20px;
    padding: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav-group-top {
    font-size: 0.85rem;
}

.nav-group-bottom {
    font-size: 0.9rem;
}

.nav-link {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    color: #666;
    text-decoration: none;
    border-radius: 18px;
    background: transparent;
    transition: all 0.3s;
    font-weight: 500;
    white-space: nowrap;
}

.nav-link i {
    margin-right: 0.3rem;
    font-size: 0.9em;
}

.nav-link:hover {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-link-primary {
    background: var(--primary-color);
    color: white;
}

.nav-link-primary:hover {
    background: #1d4ed8;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Old navbar-nav styles - remove */
.navbar-nav {
    display: none;
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
}

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

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

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

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--dark-color);
}

.btn-outline:hover {
    background-color: var(--light-color);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    position: relative;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fed7aa;
    color: #92400e;
    border: 1px solid #fdba74;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.alert .close {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
}

.alert .close:hover {
    opacity: 1;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--light-color);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: var(--light-color);
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.5rem;
}

.col {
    flex: 1;
    padding: 0.5rem;
}

.col-12 { flex: 0 0 100%; }
.col-6 { flex: 0 0 50%; }
.col-4 { flex: 0 0 33.333%; }
.col-3 { flex: 0 0 25%; }

@media (max-width: 768px) {
    .col-md-12 { flex: 0 0 100%; }
    .col-md-6 { flex: 0 0 100%; }
    .col-md-4 { flex: 0 0 100%; }
    .col-md-3 { flex: 0 0 100%; }
    
    .navbar .container {
        grid-template-columns: 1fr;
        gap: 1rem;
        text-align: center;
    }
    
    .navbar-center {
        width: 100%;
        order: 2;
    }
    
    .union-info {
        width: 100%;
    }
    
    .union-display {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
        max-width: 100%;
    }
    
    .navbar-right {
        width: 100%;
        order: 3;
        align-items: center;
    }
    
    .nav-group {
        width: 100%;
        justify-content: center;
    }
    
    .nav-link {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }
    
    .navbar-brand {
        font-size: 1.5rem;
        order: 1;
        text-align: center;
        width: 100%;
    }
    
    .dropdown-toggle-small {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }
}

/* Breadcrumbs */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.5rem;
    list-style: none;
    background: linear-gradient(135deg, #f8f9fa 0%, white 100%);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    display: inline-block;
    padding: 0 0.75rem;
    color: #94a3b8;
    content: "›";
    font-size: 1.2rem;
    font-weight: 300;
}

.breadcrumb-item a {
    color: #64748b;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    font-weight: 500;
}

.breadcrumb-item a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

.breadcrumb-item a:hover::after {
    width: 100%;
}

.breadcrumb-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Add home icon to first breadcrumb */
.breadcrumb-item:first-child a::before {
    content: "🏠";
    margin-right: 0.5rem;
    font-size: 1rem;
}

/* Alternative breadcrumb style with icons */
.breadcrumb-modern {
    display: flex;
    align-items: center;
    padding: 0;
    margin-bottom: 1.5rem;
    background: transparent;
    box-shadow: none;
    border: none;
}

.breadcrumb-modern .breadcrumb-item {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #e9ecef;
    position: relative;
    transition: all 0.3s ease;
}

.breadcrumb-modern .breadcrumb-item:first-child {
    border-radius: 25px 0 0 25px;
    padding-left: 1.25rem;
}

.breadcrumb-modern .breadcrumb-item:last-child {
    border-radius: 0 25px 25px 0;
    padding-right: 1.25rem;
}

.breadcrumb-modern .breadcrumb-item:hover {
    background: var(--primary-color);
    z-index: 1;
}

.breadcrumb-modern .breadcrumb-item:hover a {
    color: white;
}

.breadcrumb-modern .breadcrumb-item + .breadcrumb-item {
    margin-left: -1px;
}

.breadcrumb-modern .breadcrumb-item + .breadcrumb-item::before {
    display: none;
}

.breadcrumb-modern .breadcrumb-item + .breadcrumb-item::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 20px 0 20px 12px;
    border-color: transparent transparent transparent white;
    z-index: 2;
}

.breadcrumb-modern .breadcrumb-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

/* Mobile breadcrumbs */
@media (max-width: 768px) {
    .breadcrumb {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 0.5rem;
    }
    
    .breadcrumb-modern {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .breadcrumb-modern .breadcrumb-item {
        border-radius: 20px !important;
        margin-left: 0 !important;
    }
    
    .breadcrumb-modern .breadcrumb-item + .breadcrumb-item::after {
        display: none;
    }
}

/* Footer */
.footer {
    background-color: white;
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--secondary-color);
}

/* HTMX Loading States */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--light-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* HTMX Swapping */
.htmx-swapping {
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 200ms ease-in;
}

/* Dropdown Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
    display: inline-block;
    padding: 0.5rem 1rem !important;
    background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%) !important;
    color: white !important;
    border-radius: 20px !important;
    font-weight: 500 !important;
}

.dropdown-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.dropdown-toggle small {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.75rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1000;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: -1px; /* Remove gap between toggle and menu */
    top: 100%;
    left: 0;
}

/* Keep menu open when hovering over either toggle or menu */
.dropdown:hover .dropdown-menu,
.dropdown .dropdown-menu:hover {
    display: block;
}

/* Add a transparent pseudo-element to bridge any small gap */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f1f1f1;
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

.dropdown-header {
    padding: 10px 15px;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: none;
    border: none;
}

.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid #e9ecef;
}

.dropdown-section {
    margin-bottom: 0.5rem;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-muted {
    color: #6c757d !important;
}

.d-block {
    display: block !important;
}

.opacity-90 {
    opacity: 0.9 !important;
}

.opacity-75 {
    opacity: 0.75 !important;
}

.text-white {
    color: white !important;
}

.btn-outline-light {
    color: white;
    border: 1px solid white;
    background: transparent;
}

.btn-outline-light:hover {
    background: white;
    color: var(--primary-color);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.navbar-text {
    display: inline-block;
    padding: 0.5rem 1rem;
    color: #666;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }

.flex-column { flex-direction: column; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }