﻿/* Element styling using the theme variables */
body {
    background-color: var(--background);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.025em;
    transition: var(--transition-normal);
    min-height: 100vh;
    position: relative;
}

/* Header styling - UPDATED for minimal collapsed state */
.header-container {
    background: var(--card);
    border-radius: var(--card-border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    /* NEW: Expandable functionality - start collapsed */
    transition: var(--transition-normal);
    overflow: hidden;
    /* Hide entire container when collapsed */
    opacity: 0;
    max-height: 0;
    padding: 0;
    margin: 0 0 1rem 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

/* When expanded, show full header */
.header-container.expanded {
    opacity: 1;
    max-height: 400px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    background: var(--card);
}

/* NEW: Header layout wrapper - manages flex layout */
.header-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 60px;
    transition: var(--transition-normal);
    /* Hide content when collapsed */
    opacity: 0;
}

/* When expanded, change layout and show content */
.header-container.expanded .header-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    min-height: auto;
    opacity: 1;
}

.header-container.expanded .header-controls {
    justify-content: flex-end; /* Changed from center to flex-end */
    align-self: stretch; /* Changed from center to stretch */
    margin-bottom: 1rem;
    width: 100%;
}

/* NEW: Modules container with horizontal scroll */
#header-modules {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow-x: auto;
    flex: 1;
    padding-bottom: 0.25rem;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    /* NEW: Transition for expandable functionality */
    transition: var(--transition-normal);
}

/* When expanded, show all modules */
.header-container.expanded #header-modules {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    overflow: visible;
    padding: 1rem 0;
    margin: 0;
    flex: none;
}

/* Custom scrollbar styling for webkit browsers */
#header-modules::-webkit-scrollbar {
    height: 4px;
}

#header-modules::-webkit-scrollbar-track {
    background: transparent;
}

#header-modules::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

#header-modules::-webkit-scrollbar-thumb:hover {
    background: var(--info-color);
}

/* Module buttons and dropdowns - UPDATED */
.swagger-button {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    text-decoration: none;
    white-space: nowrap; /* Prevents text wrapping */
    flex-shrink: 0; /* Prevents button shrinking */
}

/* When expanded, modules can have more space */
.header-container.expanded .swagger-button {
    justify-content: center;
    width: 100%;
}

.swagger-button:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    color: white;
}

.swagger-button:active {
    transform: translateY(0);
}

.swagger-button i {
    font-size: 1.1rem;
}

/* Dropdown styling - UPDATED */
.dropdown {
    flex-shrink: 0; /* Prevents dropdown shrinking */
}

.dropdown-menu {
    background: var(--card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    margin-top: 0.5rem;
    min-width: 200px;
}

.dropdown-item {
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-item:hover {
    background: var(--hover);
    color: var(--text);
}

.dropdown-item i {
    font-size: 1.1rem;
    color: var(--info-color);
}

.dropdown-divider {
    border-color: var(--border-color);
    margin: 0.5rem 0;
}

/* Header controls (theme toggle and network status) - UPDATED */
.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0; /* Prevents shrinking */
}

/* NEW: Floating Controls Cluster - All controls grouped together */
.floating-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    background: var(--card);
    padding: 8px;
    border-radius: 25px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: var(--transition-normal);
}

/* Hide floating controls when header is expanded */
body.header-expanded .floating-controls {
    display: none !important;
}

.floating-controls:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

/* Individual control styling within floating cluster */
.floating-controls .expand-toggle,
.floating-controls .theme-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.floating-controls .expand-toggle {
    background: var(--info-color);
}

.floating-controls .theme-toggle {
    background: var(--primary-gradient);
}

.floating-controls .expand-toggle:hover,
.floating-controls .theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.floating-controls #network-connection-floating {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: var(--transition-normal);
}

.floating-controls #network-connection-floating.bg-success {
    background: var(--success-color) !important;
    color: white;
}

.floating-controls #network-connection-floating.bg-danger {
    background: var(--error-color) !important;
    color: white;
}

.floating-controls #current-time-floating {
    background: var(--card-darker);
    padding: 8px 12px;
    border-radius: 18px;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text);
    border: 1px solid var(--border-color);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

/* Update original expand toggle for header close button */
.expand-toggle-close {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    background: var(--error-color) !important;
    border: none;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.expand-toggle-close:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.expand-toggle-close i {
    font-size: 1.1rem;
}

/* Theme toggle button */
.theme-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    background: var(--primary-gradient);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
    z-index: 1000;
    flex-shrink: 0;
}

.theme-toggle:hover {
    transform: rotate(30deg) scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle i {
    font-size: 1.1rem;
    transition: var(--transition-normal);
}

/* Network status badge */
#network-connection {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
    flex-shrink: 0;
}

#network-connection.bg-success {
    background: var(--success-color) !important;
}

#network-connection.bg-danger {
    background: var(--error-color) !important;
}

/* Current time display */
#current-time {
    background: var(--card);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    height: 38px;
    display: flex;
    align-items: center;
    white-space: nowrap; /* Prevents time from wrapping */
    flex-shrink: 0; /* Prevents shrinking */
}

/* Alert styling */
.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
}

.alert-warning {
    background: linear-gradient(135deg, #ffcc00 0%, #ff9900 100%);
    color: white;
}

.alert-danger {
    background: linear-gradient(135deg, #ff3333 0%, #cc0000 100%);
    color: white;
}

/* Spinning overlay */
.spinning-overlay {
    background: var(--background-transparent-80);
    backdrop-filter: blur(4px);
}

.spinner-border {
    color: var(--info-color);
    width: 3rem;
    height: 3rem;
}

.content-container {
    min-width: 1400px;
    max-width: 2000px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* When header is expanded, make content container full width */
body.header-expanded .content-container {
    min-width: auto;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0 1rem;
}

/* Additional fix for tablet and larger screens when header is expanded */
@media (min-width: 769px) {
    body.header-expanded .content-container {
        padding: 0 1.5rem;
    }
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 2rem;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* Receiving Type Modal Styles */
#receivingTypeModal .modal-content {
    border-radius: 15px;
    border: none;
    background-color: var(--card);
}

#receivingTypeModal .modal-header {
    background: var(--card-darker);
    border-bottom: 1px solid var(--border-color);
    border-radius: 15px 15px 0 0;
    padding: 1rem 1.5rem;
}

#receivingTypeModal .modal-footer {
    background: var(--card-darker);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 15px 15px;
    padding: 1rem 1.5rem;
}

#receivingTypeModal .modal-body {
    padding: 1.5rem;
}

/* Issuance Type Modal Styles */
#issuanceTypeModal .modal-content {
    border-radius: 15px;
    border: none;
    background-color: var(--card);
}

#issuanceTypeModal .modal-header {
    background: var(--card-darker);
    border-bottom: 1px solid var(--border-color);
    border-radius: 15px 15px 0 0;
    padding: 1rem 1.5rem;
}

#issuanceTypeModal .modal-footer {
    background: var(--card-darker);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 15px 15px;
    padding: 1rem 1.5rem;
}

#issuanceTypeModal .modal-body {
    padding: 1.5rem;
}

.receiving-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.receiving-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.receiving-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-normal);
    background: var(--card);
}

.receiving-option:hover {
    border-color: var(--primary-color);
    background: var(--card-darker);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.receiving-option:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.option-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    flex-shrink: 0;
    transition: var(--transition-normal);
}

.option-icon i {
    font-size: 1.5rem;
}

.option-content {
    flex: 1;
}

.option-content h6 {
    margin: 0 0 0.25rem 0;
    font-weight: 600;
    color: var(--text);
}

.option-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Animation for receiving options */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.receiving-option {
    animation: slideInUp 0.3s ease-out;
}

.receiving-option:nth-child(1) {
    animation-delay: 0.1s;
}

.receiving-option:nth-child(2) {
    animation-delay: 0.2s;
}

.receiving-option:nth-child(3) {
    animation-delay: 0.3s;
}

.receiving-option:nth-child(4) {
    animation-delay: 0.4s;
}

.receiving-option:nth-child(5) {
    animation-delay: 0.5s;
}

.receiving-option:nth-child(6) {
    animation-delay: 0.6s;
}

/* Tablet adjustments - Fix spacing when header is expanded */
@media (max-width: 1024px) and (min-width: 769px) {
    .content-container {
        min-width: auto;
        max-width: none;
        width: 100%;
        padding: 0 1rem;
    }

    .header-container.expanded {
        margin: -1rem -1rem 1rem -1rem;
        border-radius: 0;
    }

    /* Tablet grid layout for expanded header */
    .header-container.expanded #header-modules {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.75rem;
    }
}

/* Responsive adjustments - UPDATED for floating expand button */
@media (max-width: 768px) {
    .header-container {
        border-radius: 0;
    }

    .header-container.expanded {
        padding: 1rem;
        margin-bottom: 1rem;
        margin: -1rem -1rem 1rem -1rem;
        border-radius: 0;
    }

    /* Keep single row layout on mobile but adjust sizes */
    #header-modules {
        gap: 0.5rem;
    }

    .swagger-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .header-controls {
        gap: 0.5rem;
    }

    .theme-toggle,
    #network-connection,
    .expand-toggle {
        width: 34px;
        height: 34px;
    }

    .theme-toggle i,
    #network-connection i,
    .expand-toggle i {
        font-size: 1rem;
    }

    #current-time {
        height: 34px;
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    .dropdown-menu {
        min-width: 180px;
    }

    /* On mobile, expanded view uses single column */
    .header-container.expanded #header-modules {
        grid-template-columns: 1fr !important;
    }

    .content-container {
        min-width: auto;
        max-width: none;
        width: 100%;
        padding: 0 0.5rem;
    }

    .page-title {
        font-size: 1.75rem;
    }

    /* Mobile floating button position */
    .expand-toggle {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }

    /* Responsive design for receiving and issuance modals */
    #receivingTypeModal .modal-dialog,
    #issuanceTypeModal .modal-dialog {
        margin: 1rem;
    }
    
    .receiving-option {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .option-icon {
        width: 40px;
        height: 40px;
    }
    
    .option-icon i {
        font-size: 1.25rem;
    }
    
    .option-content h6 {
        font-size: 1rem;
    }
    
    .option-content p {
        font-size: 0.85rem;
    }
}

/* Extra small screens - UPDATED for floating expand button */
@media (max-width: 480px) {
    /* When expanded on very small screens, show modules in single column */
    .header-container.expanded #header-modules {
        grid-template-columns: 1fr !important;
    }

    .header-container.expanded .header-layout {
        gap: 1rem;
    }

    /* Smaller floating button on very small screens */
    .expand-toggle {
        width: 42px;
        height: 42px;
        top: 10px;
        right: 10px;
    }

    .expand-toggle i {
        font-size: 1rem;
    }
}

/* Additional animations for expandable header */
@keyframes expandHeader {
    from {
        max-height: 80px;
    }
    to {
        max-height: 400px;
    }
}

@keyframes collapseHeader {
    from {
        max-height: 400px;
    }
    to {
        max-height: 80px;
    }
}

/* Toast notifications styling (commented out in original) */
/*.toast {
    background: var(--card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.toast-header {
    background: var(--card-darker);
    border-bottom: 1px solid var(--border-color);
    color: var(--text);
}

.toast-body {
    color: var(--text);
}*/