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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
.navbar {
    background: #2c3e50;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: bold;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a {
    color: #ecf0f1;
    text-decoration: none;
}

.nav-links a:hover {
    color: #3498db;
}

.nav-user {
    color: #95a5a6;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-logout {
    background: transparent;
    border: 1px solid #ecf0f1;
    color: #ecf0f1;
    padding: 8px 15px;
}

.btn-logout:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

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

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

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
}

.login-box h2 {
    text-align: center;
    color: #7f8c8d;
    font-weight: normal;
    margin-bottom: 30px;
}

/* Forms */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.delete-form {
    margin-top: 30px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h1 {
    color: #2c3e50;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

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

.table th,
.table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

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

.table tr.clickable-row {
    cursor: pointer;
}

.table tr.clickable-row:hover {
    background: #e8f4fc;
}

.table code {
    background: #e8e8e8;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.85rem;
}

.actions {
    display: flex;
    gap: 8px;
}

.no-data {
    padding: 40px;
    text-align: center;
    color: #7f8c8d;
}

/* Cards */
.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* Customer Details */
.customer-details .detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.customer-details .detail-row:last-child {
    border-bottom: none;
}

.customer-details strong {
    width: 150px;
    color: #7f8c8d;
}

.customer-details code {
    background: #e8e8e8;
    padding: 3px 8px;
    border-radius: 3px;
}

/* Transcripts */
.transcripts-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.transcript-card {
    border-left: 4px solid #3498db;
}

.transcript-header {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.transcript-date {
    font-weight: 500;
    color: #2c3e50;
}

.transcript-caller,
.transcript-duration {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.transcript-status {
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
}

.transcript-status.sent {
    background: #d4edda;
    color: #155724;
}

.transcript-status.pending {
    background: #fff3cd;
    color: #856404;
}

.transcript-audio {
    margin-bottom: 15px;
}

.transcript-audio audio {
    width: 100%;
    max-width: 400px;
}

.transcript-content pre {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.back-link {
    margin-top: 30px;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 60px 20px;
}

.error-page h1 {
    color: #e74c3c;
    margin-bottom: 20px;
}

.error-page p {
    color: #7f8c8d;
    margin-bottom: 30px;
}

/* Filter Section */
.filter-section {
    margin-bottom: 20px;
}

.filter-form .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-weight: 500;
}

.filter-group input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    min-width: 150px;
}

.filter-group input:focus {
    outline: none;
    border-color: #3498db;
}

.filter-buttons {
    display: flex;
    gap: 10px;
}

/* Transcript Items (Collapsible) */
.transcript-item {
    border-left: 4px solid #3498db;
    padding: 0;
}

.transcript-item .transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    margin-bottom: 0;
    border-bottom: none;
    transition: background 0.2s;
}

.transcript-item .transcript-header:hover {
    background: #f8f9fa;
}

.transcript-summary {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.transcript-meta {
    display: flex;
    gap: 15px;
    align-items: center;
}

.transcript-toggle {
    color: #7f8c8d;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.transcript-details {
    padding: 0 20px 20px 20px;
    border-top: 1px solid #eee;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
    padding: 20px;
}

.pagination-info {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Warning Badge in Nav */
.nav-warnings {
    position: relative;
}

.warning-badge {
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
    font-weight: bold;
}

/* Warnings Page */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: normal;
    margin-left: 10px;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.warnings-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.warning-item {
    border-left: 4px solid #e74c3c;
}

.warning-item.read {
    border-left-color: #95a5a6;
    opacity: 0.7;
}

.warning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.warning-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.warning-type {
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.warning-type.customer_not_found {
    background: #f8d7da;
    color: #721c24;
}

.warning-type.email_failed {
    background: #fff3cd;
    color: #856404;
}

.warning-date {
    color: #7f8c8d;
    font-size: 0.85rem;
}

.warning-actions {
    display: flex;
    gap: 8px;
}

.warning-message {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #333;
}

.warning-meta {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.warning-meta code {
    background: #e8e8e8;
    padding: 2px 6px;
    border-radius: 3px;
}

.warning-details {
    margin-top: 10px;
}

.warning-details pre {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    overflow-x: auto;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    min-width: 180px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-back {
    padding: 8px 15px;
}

/* Combined Audio + Transcript View */
.transcript-combined {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.transcript-audio-section,
.transcript-content-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.transcript-audio-section h4,
.transcript-content-section h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 0.95rem;
}

.transcript-audio-section audio {
    width: 100%;
    max-width: 500px;
}

.transcript-audio-section.no-audio {
    background: #f5f5f5;
    border: 1px dashed #ddd;
}

.muted {
    color: #95a5a6;
    font-style: italic;
    margin: 0;
}

/* Form Sections & Checkboxes */
.form-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.form-section h3 {
    margin: 0 0 5px 0;
    color: #2c3e50;
}

.form-hint {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.checkbox-group {
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: #f8f9fa;
}

.checkbox-label.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
}

.checkbox-label span {
    font-weight: 500;
    color: #2c3e50;
}

.checkbox-label small {
    display: block;
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* Badges */
.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-inactive {
    background: #e9ecef;
    color: #6c757d;
}

.badge-transcript {
    background: #cce5ff;
    color: #004085;
}

.badge-audio {
    background: #fff3cd;
    color: #856404;
}

.email-settings {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Calls List */
.calls-list {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 30px;
}

.call-row {
    display: grid;
    grid-template-columns: 180px 140px 60px 1fr 100px;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    align-items: center;
}

.call-row:last-child {
    border-bottom: none;
}

.call-row:hover {
    background: #f8f9fa;
}

.call-row-date {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
}

.call-row-caller {
    color: #555;
    font-size: 0.9rem;
}

.call-row-duration {
    color: #7f8c8d;
    font-size: 0.85rem;
    text-align: center;
}

.call-row-badges {
    display: flex;
    gap: 5px;
}

.call-row-badges .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
}

.call-row-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.sent {
    background: #28a745;
}

.status-dot.pending {
    background: #ffc107;
}

/* Liste Header */
.call-header {
    background: #f8f9fa;
    font-size: 0.8rem;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    cursor: default !important;
}

.call-header:hover {
    background: #f8f9fa !important;
}

/* Responsive Liste */
@media (max-width: 900px) {
    .call-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .call-row-duration {
        text-align: left;
    }

    .call-header {
        display: none;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 700px;
    margin: 40px 0;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

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

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #7f8c8d;
    line-height: 1;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 20px;
}

.modal-meta {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.modal-meta p {
    margin: 5px 0;
}

.modal-email-info {
    margin-bottom: 20px;
}

.modal-email-info h4 {
    margin: 0 0 10px 0;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.email-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.modal-section audio {
    width: 100%;
}

.modal-transcript {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
    font-size: 0.9rem;
    max-height: 300px;
    overflow-y: auto;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

/* Category Badges */
.category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-ai-active {
    background: #27ae60;
    color: white;
}

/* AI Settings Section */
.ai-settings-section {
    margin-top: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Rules Table */
.rules-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rule-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 12px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 5px;
}

.rule-category {
    flex: 0 0 110px;
}

.rule-fields {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.rule-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.9rem;
}

.rule-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.rule-recipients {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    min-width: 200px;
}

.rule-recipients:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Modal AI Info */
.modal-ai-info {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.modal-ai-info h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

/* Call row category */
.call-row-category {
    display: flex;
    align-items: center;
}

.call-row-category .category-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* Responsive rules */
@media (max-width: 768px) {
    .rule-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .rule-fields {
        flex-direction: column;
        width: 100%;
        align-items: flex-start;
    }

    .rule-recipients {
        width: 100%;
        min-width: auto;
    }
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #95a5a6;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

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

    .customer-details .detail-row {
        flex-direction: column;
    }

    .customer-details strong {
        width: auto;
        margin-bottom: 5px;
    }
}
