/* Amateur Radio Callsign Lookup System - Ham Radio Themed CSS */

:root {
    --ham-orange: #ff6b35;
    --ham-blue: #1e3d59;
    --ham-green: #2ecc71;
    --ham-gray: #34495e;
    --ham-light-gray: #ecf0f1;
    --ham-dark-gray: #2c3e50;
    --background: #f5f7fa;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --table-header: #3498db;
    --table-row-even: #f8f9fa;
    --table-row-hover: #e3f2fd;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #e8ecf0 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 20px 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, var(--ham-blue) 0%, var(--ham-dark-gray) 100%);
    color: white;
    padding: 0.5rem;
    border-radius: 15px 15px 0 0;
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow-medium);
    margin-bottom: 0;
}

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

.subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
    font-weight: 300;
}

.chat-container {
    background: white;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 4px 20px var(--shadow-medium);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
}

.chat-messages {
    flex-grow: 1;
    padding: 1.5rem 1.5rem 120px;
    overflow-y: auto;
    border-bottom: none;
}

.message {
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.3s ease-out;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    max-width: 85%;
    box-shadow: 0 2px 10px var(--shadow-light);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--ham-orange) 0%, #e74c3c 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
    background: linear-gradient(135deg, var(--ham-light-gray) 0%, #ffffff 100%);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    max-width: 98%; /* Allow wider for table results */
}

.assistant-message .message-content strong {
    color: var(--ham-blue);
}

/* Callsign information display */
.callsign-info {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    border: 1px solid var(--ham-green);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.callsign-info h4 {
    color: var(--ham-green);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.callsign-details {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.callsign-detail {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(46, 204, 113, 0.2);
}

.callsign-detail strong {
    color: var(--ham-dark-gray);
    min-width: 120px;
    flex-shrink: 0;
}

.callsign-detail span {
    flex-grow: 1;
    text-align: right;
    margin-left: 1rem;
}

/* External links section */
.external-links {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 2px solid rgba(46, 204, 113, 0.3);
}

.external-links h5 {
    color: var(--ham-green);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.external-links a {
    display: inline-block;
    background: var(--ham-blue);
    color: white;
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin: 0.2rem 0.3rem 0.2rem 0;
    transition: background-color 0.3s ease;
}

.external-links a:hover {
    background: var(--ham-orange);
    transform: translateY(-1px);
}

/* Results table for multiple results */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
    box-shadow: 0 4px 8px var(--shadow-light);
    border-radius: 8px;
    overflow: hidden;
}

.results-table th {
    background: var(--table-header);
    color: white;
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.results-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.results-table tbody tr:nth-child(even) {
    background-color: var(--table-row-even);
}

.results-table tbody tr:hover {
    background-color: var(--table-row-hover);
    cursor: pointer;
}

/* Clickable callsigns in table */
.clickable-callsign {
    color: var(--ham-blue);
    font-weight: bold;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.clickable-callsign:hover {
    color: var(--ham-orange);
}

/* Status indicators */
.status-active {
    color: var(--ham-green);
    font-weight: 600;
}

.status-expired {
    color: #e74c3c;
    font-weight: 600;
}

.status-cancelled {
    color: #f39c12;
    font-weight: 600;
}

/* License class badges */
.license-badge {
    background: var(--ham-gray);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.license-badge.extra { background: #8e44ad; }
.license-badge.advanced { background: #e67e22; }
.license-badge.general { background: #3498db; }
.license-badge.technician { background: #27ae60; }
.license-badge.novice { background: #95a5a6; }

.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 20px;
    background: var(--ham-light-gray);
    border-top: 2px solid var(--border-color);
    box-shadow: 0 -4px 20px var(--shadow-medium);
    z-index: 100;
    max-width: 1400px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#messageInput {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    height: 48px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: white;
}

#messageInput:focus {
    outline: none;
    border-color: var(--ham-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

#sendButton {
    background: linear-gradient(135deg, var(--ham-orange) 0%, #e74c3c 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    height: fit-content;
    box-shadow: 0 2px 8px var(--shadow-light);
}

#sendButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-medium);
}

#sendButton:active {
    transform: translateY(0);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}


.footer-text a {
    color: var(--ham-orange);
    text-decoration: none;
}

.footer-text a:hover {
    text-decoration: underline;
}

.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-medium);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
    color: var(--ham-blue);
    z-index: 1000;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--ham-light-gray);
    border-top: 3px solid var(--ham-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Enhanced message styling */
.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.message-content em {
    color: var(--text-secondary);
    font-style: italic;
}

.message-content code {
    background: rgba(0,0,0,0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Result count display */
.result-count {
    background: var(--ham-light-gray);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0 1rem 0;
    font-size: 0.9rem;
    color: var(--ham-dark-gray);
    text-align: center;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px 10px 0;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .message-content {
        max-width: 95%;
    }
    
    .input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    #sendButton {
        margin-top: 0.5rem;
    }
    
    .input-footer {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
    
    .input-container {
        padding: 1rem 10px;
    }
    
    .chat-messages {
        padding: 1rem 1rem 140px;
    }
    
    .results-table {
        font-size: 0.8rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 0.4rem 0.3rem;
    }
    
    /* Stack table cells on mobile */
    .results-table thead {
        display: none;
    }
    
    .results-table tbody tr {
        display: block;
        border: 1px solid #ccc;
        margin-bottom: 0.5rem;
        border-radius: 8px;
        padding: 0.5rem;
    }
    
    .results-table td {
        display: block;
        border: none;
        text-align: right;
        padding: 0.2rem 0;
    }
    
    .results-table td:before {
        content: attr(data-label) ": ";
        float: left;
        font-weight: bold;
        color: var(--ham-blue);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .input-container {
        padding: 1rem;
    }
    
    #messageInput {
        height: 50px;
    }
    
    .chat-messages {
        padding: 1rem 1rem 160px;
    }
}

/* Action buttons */
.action-buttons {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.distance-calc-btn, .repeater-search-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.distance-calc-btn {
    background: var(--ham-blue);
    color: white;
}

.distance-calc-btn:hover {
    background: var(--ham-orange);
}

.repeater-search-btn {
    background: var(--ham-green);
    color: white;
}

.repeater-search-btn:hover {
    background: #27ae60;
}

/* Table action buttons */
.action-cell {
    white-space: nowrap;
}

.small-distance-btn, .small-repeater-btn {
    padding: 0.25rem 0.5rem;
    margin: 0 0.1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.small-distance-btn {
    background: var(--ham-blue);
    color: white;
}

.small-distance-btn:hover {
    background: var(--ham-orange);
}

.small-repeater-btn {
    background: var(--ham-green);
    color: white;
    text-decoration: none;
    display: inline-block;
}

.small-repeater-btn:hover {
    background: #27ae60;
}

/* Bulk action buttons */
.bulk-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.export-csv-btn, .view-map-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.export-csv-btn {
    background: #16a085;
    color: white;
}

.export-csv-btn:hover {
    background: #1abc9c;
}

.view-map-btn {
    background: #8e44ad;
    color: white;
}

.view-map-btn:hover {
    background: #9b59b6;
}

/* Modal styles */
.distance-modal, .map-modal, .repeater-modal {
    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: 1000;
}

.distance-modal-content, .map-modal-content, .repeater-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.map-modal-content {
    max-width: 900px;
}

.close-modal {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ham-gray);
}

.close-modal:hover {
    color: var(--ham-orange);
}

.distance-form {
    margin-top: 1rem;
}

.from-section, .to-section {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--ham-light-gray);
    border-radius: 6px;
}

.to-section input {
    width: 100%;
    padding: 0.5rem;
    margin: 0.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#use-my-location, #calculate-distance {
    padding: 0.5rem 1rem;
    background: var(--ham-blue);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 0.5rem 0;
}

#use-my-location:hover, #calculate-distance:hover {
    background: var(--ham-orange);
}

.distance-results {
    margin-top: 1rem;
    padding: 1rem;
    background: #e8f5e8;
    border: 1px solid var(--ham-green);
    border-radius: 6px;
}

.distance-detail {
    margin: 0.5rem 0;
}

/* Repeater modal styles */
.repeater-info {
    margin-top: 1rem;
}

.repeater-info ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.repeater-info code {
    background: #f0f0f0;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.repeater-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

.repeater-actions button, .repeater-site-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    border: none;
    transition: all 0.3s ease;
}

.repeater-actions button {
    background: #95a5a6;
    color: white;
}

.repeater-actions button:hover {
    background: #7f8c8d;
}

.repeater-site-btn {
    background: var(--ham-green);
    color: white;
    text-decoration: none;
    display: inline-block;
}

.repeater-site-btn:hover {
    background: #27ae60;
}

/* Print styles */
@media print {
    .input-container,
    .loading-indicator {
        display: none;
    }
    
    .chat-container {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
    
    .external-links a {
        color: var(--ham-blue) !important;
        background: none !important;
        text-decoration: underline !important;
    }
}