/* VoiceAI Relay - Unified Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout Structure */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* API Examples Styling */
.api-example {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    background: #fafafa;
}

.api-example h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2rem;
}

.api-example h4 {
    margin-bottom: 8px;
    color: #555;
    font-size: 1rem;
    font-weight: 600;
}

.api-method {
    margin-bottom: 15px;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 4px;
    border-left: 4px solid #2196F3;
}

.api-method code {
    background: transparent;
    color: #1976D2;
    font-weight: 600;
    font-size: 1rem;
}

.api-headers pre,
.api-payload pre,
.api-curl pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
}

.api-headers code,
.api-payload code,
.api-curl code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.api-payload,
.api-headers,
.api-curl {
    margin-bottom: 15px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
}

.container {
    max-width: 1200px;
    min-width: 1200px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    flex: 1;
}

.main-content {
    flex: 1;
    padding: 40px 30px;
}

/* Header */
.header {
    background: #333;
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: normal;
}

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

/* Navigation */
.nav-bar {
    background: #444;
    padding: 15px;
    text-align: center;
    border-bottom: 3px solid #007cba;
}

.nav-link {
    color: #ccc;
    text-decoration: none;
    margin: 0 15px;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: inline-block;
}

.nav-link:hover, .nav-link.active {
    background: #555;
    color: white;
    transform: translateY(-2px);
}

/* Footer */
.footer {
    background: #333;
    color: white;
    padding: 30px;
    text-align: center;
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.footer-link {
    color: #ccc;
    text-decoration: none;
    padding: 10px 20px;
    border: 1px solid #555;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.footer-link:hover {
    background: #555;
    color: white;
    border-color: #777;
}

.footer-text {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-right: 10px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #007cba;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #005a87;
    transform: translateY(-1px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover:not(:disabled) {
    background: #e0a800;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #138496;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

textarea {
    font-family: monospace;
    resize: vertical;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Cards and Sections */
.section {
    margin-bottom: 40px;
    padding: 0 10px;
}

.section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.4rem;
    border-bottom: 2px solid #007cba;
    padding-bottom: 8px;
}

.feature-card, .maintenance-card, .stat-card {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.stat-card {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: default;
}

.stat-card h3 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: #007cba;
}

.stat-card p {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.feature-card:hover, .maintenance-card:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.feature-title, .card-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.feature-description, .card-description {
    color: #666;
    line-height: 1.5;
    margin-bottom: 15px;
    font-size: 14px;
}

/* Grids */
.features-grid, .maintenance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 30px;
}

.filter-grid.logs-filters {
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 25px;
}

/* Tables */
table, .calls-table, .stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
}

.logs th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.logs td {
    font-size: 14px;
    vertical-align: middle;
}

tbody tr:hover {
    background: #f8f9fa;
}

.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
    margin-top: 30px;
    margin-bottom: 30px;
}

.table-container table {
    margin: 0;
}

.logs .table-container {
    overflow-x: auto;
}

/* Status Badges */
.status-badge, .status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-dispatched { background: #fff3cd; color: #856404; }
.status-dialing { background: #cce5ff; color: #0056b3; }
.status-connected { background: #d1ecf1; color: #0c5460; }
.status-bridged { background: #d4edda; color: #155724; }
.status-ended { background: #d4edda; color: #155724; }
.status-failed { background: #f8d7da; color: #721c24; }
.status-busy { background: #f8d7da; color: #721c24; }
.status-no_answer { background: #f8d7da; color: #721c24; }
.status-cancelled { background: #d1ecf1; color: #0c5460; }
.status-successful { background: #d4edda; color: #155724; }
.status-pending { background: #fff3cd; color: #856404; }

/* Alerts and Messages */
.alert {
    padding: 12px;
    border-radius: 4px;
    margin: 15px 0;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }

.warning-box {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 30px;
    border-left: 4px solid #e17055;
}

.warning-title {
    font-weight: bold;
    color: #856404;
    margin-bottom: 10px;
}

.warning-text {
    color: #856404;
    font-size: 14px;
}

/* Progress and Stats */
.progress-container {
    display: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 25px;
    background: #f9f9f9;
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 15px 0;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: #007cba;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: bold;
}

.stats-section {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #ddd;
}

.stats-title {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #333;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    text-align: center;
}

.stat, .stat-item, .detail-item {
    flex: 1;
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    margin: 0 10px;
}

.stat-value, .stat-number, .detail-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #007cba;
    margin-bottom: 5px;
}

.stat-label, .detail-label {
    color: #666;
    font-size: 0.9rem;
}

.call-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Call Status and Logs */
.call-status {
    display: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 25px;
    background: #f9f9f9;
    margin-top: 20px;
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.call-log, .log-container {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.log-entry {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.info { border-left: 4px solid #3498db; }
.log-entry.warn { border-left: 4px solid #f39c12; }
.log-entry.error { border-left: 4px solid #e74c3c; }
.log-entry.debug { border-left: 4px solid #95a5a6; }

.log-time, .log-timestamp {
    color: #666;
    font-weight: bold;
}

.log-message {
    margin-left: 10px;
}

/* Modals */
.call-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.call-details-content {
    background: white;
    max-width: 800px;
    max-height: 80%;
    overflow-y: auto;
    border-radius: 8px;
    padding: 20px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px 0;
    gap: 15px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.pagination button {
    padding: 10px 16px;
    border: 2px solid #dee2e6;
    background: white;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination span {
    font-weight: 600;
    color: #495057;
}

/* Filters */
.filters {
    background: white;
    padding: 40px;
    border-radius: 12px;
    margin-bottom: 40px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.filters h3 {
    margin-bottom: 30px;
    font-size: 1.3rem;
    color: #333;
    font-weight: 600;
}

.filter-group {
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.filter-group label {
    margin-bottom: 10px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    border: 2px solid #dee2e6;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
    outline: none;
}

.filter-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 35px;
    padding-top: 25px;
    border-top: 2px solid #e9ecef;
    justify-content: flex-start;
}

/* Confirmations */
.confirm-action {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 15px;
    margin: 10px 0;
    display: none;
}

.confirm-buttons {
    margin-top: 10px;
}

/* Loading and Utilities */
.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

.hidden {
    display: none !important;
}

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

.text-muted {
    color: #666;
}

.example {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    margin-top: 5px;
    color: #666;
}

.info-text {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    padding: 8px;
    border-radius: 4px;
    margin-top: 5px;
    font-size: 13px;
    color: #0066cc;
}

.page-wrapper.maintenance .header {
    background: #dc3545;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    .features-grid, .maintenance-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        max-width: none;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .filter-grid.logs-filters {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .filter-group {
        padding: 15px;
    }
    
    .filters {
        padding: 25px;
    }
    
    .call-details {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .nav-link {
        margin: 5px;
        display: inline-block;
    }
    
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .stat, .stat-item, .detail-item {
        margin: 0;
    }
    
    .filter-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    
    table {
        font-size: 14px;
    }
    
    th, td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 20px 15px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .nav-bar {
        padding: 10px;
    }
    
    .nav-link {
        display: block;
        margin: 5px 0;
        text-align: center;
    }
}

/* Modern Toggle Radio Buttons */
.input-method-toggle {
    margin: 15px 0;
}

.main-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #333;
}

.toggle-container {
    display: flex;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid #e9ecef;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 400px;
}

.toggle-container:hover {
    border-color: #007cba;
}

.toggle-container input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 6px;
    background: transparent;
    color: #6c757d;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.toggle-option:hover {
    color: #495057;
    background: rgba(0,124,186,0.05);
}

.toggle-container input[type="radio"]:checked + .toggle-option {
    background: linear-gradient(135deg, #007cba, #005a87);
    color: white;
    font-weight: 600;
}

.toggle-icon {
    font-size: 14px;
    margin-right: 6px;
    transition: transform 0.3s ease;
}

.toggle-container input[type="radio"]:checked + .toggle-option .toggle-icon {
    transform: scale(1.1);
}

.toggle-text {
    font-size: 13px;
    white-space: nowrap;
}

/* Animation for smooth transitions */
.toggle-container::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: linear-gradient(135deg, #007cba, #005a87);
    border-radius: 6px;
    z-index: 0;
    opacity: 0;
}

.toggle-container:has(input[name="inputMethod"]:first-of-type:checked)::before {
    transform: translateX(0);
    opacity: 1;
}

.toggle-container:has(input[name="inputMethod"]:last-of-type:checked)::before {
    transform: translateX(100%);
    opacity: 1;
}

/* Responsive adjustments for toggle */
@media (max-width: 768px) {
    .toggle-container {
        flex-direction: column;
        padding: 4px;
        max-width: 300px;
    }
    
    .toggle-container::before {
        width: calc(100% - 8px);
        height: calc(50% - 4px);
    }
    
    .toggle-container:has(input[name="inputMethod"]:first-of-type:checked)::before {
        transform: translateY(0);
    }
    
    .toggle-container:has(input[name="inputMethod"]:last-of-type:checked)::before {
        transform: translateY(100%);
    }
    
    .toggle-option {
        padding: 8px 12px;
    }
    
    .toggle-text {
        font-size: 12px;
    }
}

/* Row layout for batch parameters */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: -10px -5px;
}

.col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 10px 5px;
}

@media (max-width: 768px) {
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}