* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 95%;
    margin: 0 auto;
    padding: 20px;
}

/* Limit container width on very large screens */
@media (min-width: 1920px) {
    .container {
        max-width: 1800px;
    }
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.auth-status {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.auth-status.authenticated {
    background: rgba(40, 167, 69, 0.3);
}

.auth-status.unauthenticated {
    background: rgba(220, 53, 69, 0.3);
}

.main-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.nav-buttons {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.nav-button {
    flex: 1;
    padding: 20px;
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
}

.nav-button:hover {
    background: #e9ecef;
    color: #007bff;
}

.nav-button.active {
    background: #007bff;
    color: white;
}

.content-area {
    padding: 40px;
    min-height: 400px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.check-section {
    text-align: center;
}

.check-button {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.check-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.check-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.result-area {
    margin-top: 30px;
    padding: 20px;
    border-radius: 8px;
    display: none;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-card {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.result-card.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
}

.result-card.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
}

.result-icon {
    font-size: 2rem;
    margin-right: 15px;
    font-weight: bold;
}

.result-card.success .result-icon {
    color: #28a745;
}

.result-card.error .result-icon {
    color: #dc3545;
}

.result-details {
    flex: 1;
}

.result-filename {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.result-status {
    font-size: 0.9rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.result-card.success .result-status {
    color: #155724;
}

.result-card.error .result-status {
    color: #721c24;
}

.result-info {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.8;
}

.result-info div {
    margin-bottom: 3px;
}

.result-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.result-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.placeholder-text {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 40px;
}

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.auth-message {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
}

.auth-message h2 {
    color: #007bff;
    margin-bottom: 20px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .nav-buttons {
        flex-direction: column;
    }

    .nav-button {
        padding: 15px;
    }

    .content-area {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 1rem;
    }

    .check-button {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

/* Query Interface Styles */
.query-section {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* Limit width for form elements but not results */
.query-section .query-group,
.query-section .query-actions,
.query-section .payload-display {
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

/* Allow query results to use full width */
.query-section .query-results {
    max-width: 100%;
    margin: 20px 0;
}

.query-type-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.query-type-button {
    padding: 10px 20px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    transition: all 0.3s ease;
}

.query-type-button:hover {
    background: #e9ecef;
    border-color: #007bff;
    color: #007bff;
}

.query-type-button.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.query-type-content {
    display: none;
}

.query-type-content.active {
    display: block;
}

.query-group {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.query-group h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
}

.logic-selector {
    margin-bottom: 15px;
}

.logic-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: normal;
}

.logic-selector input[type="radio"] {
    margin-right: 8px;
}

.family-selector {
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
}

.platform-category-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.selector-group h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #6c757d;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.checkbox-group.multi-column.hidden {
    display: none !important;
}

.checkbox-group.multi-column {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px;
    max-width: 100%;
}

.checkbox-group.multi-column label {
    display: flex !important;
    align-items: center;
    font-weight: normal;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

@media (max-width: 768px) {
    .checkbox-group.multi-column {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 480px) {
    .checkbox-group.multi-column {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
    font-size: 0.9rem;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
}

.generation-selector {
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
}

.size-selector > label {
    display: block;
    margin-bottom: 10px;
    font-weight: normal;
}

.query-actions {
    text-align: center;
    margin: 30px 0;
}

.query-button {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.query-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.query-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.query-results {
    margin-top: 30px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007bff;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.export-button {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.export-button:hover {
    background: #218838;
}

.results-table-container {
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 15px;
    max-height: 600px;
    width: 100%;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 800px; /* Ensure table has minimum width for readability */
}

/* On larger screens, allow table to expand beyond minimum */
@media (min-width: 1200px) {
    .results-table {
        min-width: 100%;
    }
}

.results-table th,
.results-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    white-space: nowrap;
}

/* Center numeric columns */
.results-table td.center,
.results-table th.center {
    text-align: center;
}

/* Clickable name links */
.results-table .name-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

.results-table .name-link:hover {
    color: #0056b3;
}

/* Service and hostclass links - blue */
.results-table .service-link,
.results-table .hostclass-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

.results-table .service-link:hover,
.results-table .hostclass-link:hover {
    color: #0056b3;
}

/* Capdef links - orange */
.results-table .capdef-link {
    color: #ff8c00;
    text-decoration: underline;
    cursor: pointer;
}

.results-table .capdef-link:hover {
    color: #cc7000;
}

/* CTI ticket icon */
.cti-ticket-icon {
    cursor: pointer;
    margin-right: 5px;
    font-size: 1.1em;
    vertical-align: middle;
}

.cti-ticket-icon:hover {
    opacity: 0.7;
}

/* Sort indicator */
.sort-indicator {
    margin-left: 5px;
    font-size: 0.8em;
}

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

/* Modal dialog */
.modal-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

/* Ticket dialog - responsive width */
#ctiTicketDialog .modal-dialog {
    max-width: 400px;
    width: 90%;
}

@media (max-width: 768px) {
    #ctiTicketDialog .modal-dialog {
        width: 90%;
    }
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.modal-error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
}

.detail-label {
    font-weight: 600;
    color: #495057;
}

.detail-value {
    color: #333;
}

.copy-button {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.copy-button:hover {
    background: #0056b3;
}

/* Mobile responsiveness for modal */
@media (max-width: 768px) {
    .modal-dialog {
        width: 95%;
        max-height: 90vh;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.results-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #dee2e6;
}

.results-table tr:hover {
    background: #f8f9fa;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.pagination-controls button {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.pagination-controls button:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.pagination-controls button:hover:not(:disabled) {
    background: #0056b3;
}

/* Payload Display Styles */
.payload-display {
    margin: 30px 0;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
}

.payload-header {
    background: #e9ecef;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
}

.payload-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
}

.payload-content {
    padding: 20px;
}

.payload-content pre {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin: 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #495057;
}

@media (max-width: 768px) {
    .platform-category-selector {
        grid-template-columns: 1fr;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Debug log specific styles */
#debugMessages {
    scroll-behavior: smooth;
}

#debugMessages div {
    margin-bottom: 2px;
}


/* About section centering */
#about {
    text-align: center;
}

#aboutContent {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

#aboutContent p {
    text-align: center;
}

/* ===== Usage Dashboard Styles ===== */

/* Dashboard header */
.dashboard-header {
    margin-bottom: 20px;
}

.dashboard-title {
    font-size: 1.6rem;
    color: #333;
    margin-bottom: 8px;
}

.dashboard-disclaimer {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 12px;
}

.dashboard-date-label {
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 16px;
    font-style: italic;
}

/* Dashboard controls (date range + scale selectors) */
.dashboard-controls {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dashboard-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-control-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
}

.dashboard-selector {
    display: flex;
    gap: 4px;
}

.dashboard-selector-btn {
    padding: 6px 14px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    transition: all 0.2s ease;
}

.dashboard-selector-btn:hover {
    background: #e9ecef;
    border-color: #007bff;
    color: #007bff;
}

.dashboard-selector-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

/* Metric cards grid */
.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-metric-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dashboard-metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #007bff;
    margin-bottom: 4px;
}

.dashboard-metric-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 500;
}

/* Dashboard body */
.dashboard-body {
    margin-top: 10px;
}

/* Section titles */
.dashboard-section-title {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Top users table */
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.dashboard-table th,
.dashboard-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.dashboard-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.dashboard-table tr:hover {
    background: #f8f9fa;
}

.dashboard-no-data {
    color: #6c757d;
    font-style: italic;
    padding: 16px 0;
}

/* Breakdown sections */
.dashboard-breakdown {
    margin-bottom: 24px;
}

.dashboard-breakdown-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dashboard-breakdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 14px;
}

.dashboard-breakdown-type {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.dashboard-breakdown-count {
    font-weight: 700;
    color: #007bff;
    font-size: 0.9rem;
}

/* Chart containers */
.dashboard-charts {
    margin-bottom: 24px;
}

.dashboard-chart-wrapper {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

/* Loading state */
.dashboard-loading {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

/* Error state */
.dashboard-error {
    text-align: center;
    padding: 40px 20px;
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin: 20px 0;
}

.dashboard-retry-button {
    margin-top: 12px;
    padding: 8px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s ease;
}

.dashboard-retry-button:hover {
    background: #0056b3;
}

/* Charts unavailable fallback */
.dashboard-charts-unavailable {
    text-align: center;
    padding: 20px;
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    margin: 20px 0;
}

/* Responsive: stack metric cards on smaller screens */
@media (max-width: 992px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .dashboard-metrics {
        grid-template-columns: 1fr;
    }

    .dashboard-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-breakdown-list {
        flex-direction: column;
    }
}
