/* CSS Custom Properties - Color Palette */
:root {
    /* Primary Colors */
    --primary-blue: #163b65;
    --primary-blue-dark: #357ab8;
    --primary-blue-darker: #205081;
    
    /* Background Colors */
    --bg-body: #f7f9fa;
    --bg-white: #fff;
    --bg-light: #f3f5f7;
    --bg-lighter: #f9fafb;
    --bg-blue-light: #f3f7fa;
    --bg-blue-lighter: #eaf1fa;
    --bg-gray-light: #f7f7f7;
    
    /* Text Colors */
    --text-primary: #222;
    --text-secondary: #2b2b2b;
    --text-tertiary: #333;
    --text-white: #fff;
    --text-blue: #153f6f;
    --text-blue-dark: #357ab8;
    --text-blue-darker: #205081;
    
    /* Border Colors */
    --border-light: #e5e7eb;
    --border-medium: #cfd8dc;
    --border-blue: #b5c6df;
    --border-gray: #e3e3e3;
    
    /* Status Colors */
    --error-bg: #e74c3c;
    --error-bg-dark: #c0392b;
    --warning-bg: #f9e79f;
    --warning-text: #b7950b;
    --warning-border: #f7ca18;
    
    /* Header/Footer */
    --header-bg: #222e3a;
    
    /* Shadows */
    --shadow-light: rgba(44,62,80,0.04);
    --shadow-medium: rgba(44,62,80,0.06);
    --shadow-strong: rgba(44,62,80,0.07);
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    line-height: 1.7;
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 18px;
}

header {
    background: var(--header-bg);
    color: var(--text-white);
    padding: 1.5rem 0 1rem 0;
    text-align: center;
    border-bottom: 3px solid var(--primary-blue);
}

h1 {
    font-size: 2.4rem;
    margin: 0;
    letter-spacing: 1px;
}

main {
    margin-top: 30px;
    margin-bottom: 30px;
}

.panel-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    justify-content: space-between;
}

.panel {
    flex: 1 1 320px;
    min-width: 320px;
    background: none;
    box-shadow: none;
    border: none;
    padding: 0;
}

#results-display.panel {
    flex: 1 1 100%;
    min-width: 0;
    margin-top: 32px;
}

/* Dialog Table Styles */
#dialog-items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: 8px;
    overflow: hidden;
    font-size: 1rem;
    margin-bottom: 0;
    table-layout: fixed;
}

#dialog-items-table th, #dialog-items-table td {
    padding: 7px 10px;
    border: 1px solid var(--border-light);
    text-align: left;
    vertical-align: middle;
    font-weight: 300;
    font-size: 0.97rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Widen the Text/Duration column */
#dialog-items-table th:nth-child(3), #dialog-items-table td:nth-child(3) {
    min-width: 320px;
    width: 50%;
    font-weight: 300;
    font-size: 1rem;
}

/* Make the Speaker (2nd) column narrower */
#dialog-items-table th:nth-child(2), #dialog-items-table td:nth-child(2) {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    text-align: center;
}

/* Make the Actions (4th) column narrower */
#dialog-items-table th:nth-child(4), #dialog-items-table td:nth-child(4) {
    width: 110px;
    min-width: 90px;
    max-width: 130px;
    text-align: left;
    padding-left: 0;
    padding-right: 0;
}

#dialog-items-table th:first-child, #dialog-items-table td.type-icon-cell {
    width: 44px;
    min-width: 36px;
    max-width: 48px;
    text-align: center;
    padding-left: 0;
    padding-right: 0;
}

.type-icon-cell {
    text-align: center;
    vertical-align: middle;
}

.dialog-type-icon {
    font-size: 1.4em;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
}

#dialog-items-table th {
    background: var(--bg-light);
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 1.05rem;
}

#dialog-items-table tr:last-child td {
    border-bottom: none;
}

#dialog-items-table td.actions {
    text-align: left;
    min-width: 110px;
    white-space: nowrap;
}

/* Collapsible log details */
details#generation-log-details {
    margin-bottom: 0;
    border-radius: 4px;
    background: var(--bg-light);
    box-shadow: 0 1px 3px var(--shadow-light);
    padding: 0 0 0 0;
    transition: box-shadow 0.15s;
}

details#generation-log-details[open] {
    box-shadow: 0 2px 8px var(--shadow-strong);
    background: var(--bg-lighter);
}

details#generation-log-details summary {
    font-size: 1rem;
    color: var(--text-blue);
    padding: 10px 0 6px 0;
    outline: none;
}

details#generation-log-details summary:focus {
    outline: 2px solid var(--primary-blue);
    border-radius: 3px;
}

@media (max-width: 900px) {
    .panel-grid {
        display: block;
        gap: 0;
    }
    .panel, .full-width-panel {
        min-width: 0;
        width: 100%;
        flex: 1 1 100%;
    }
    #dialog-items-table th, #dialog-items-table td {
        font-size: 0.97rem;
        padding: 7px 8px;
    }
    #speaker-management.panel {
        margin-bottom: 36px;
        width: 100%;
        max-width: 100%;
        flex: 1 1 100%;
    }
}

.card {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow-medium);
    padding: 18px 20px;
    margin-bottom: 18px;
}

section {
    margin-bottom: 0;
    border-radius: 0;
    padding: 0;
    background: none;
}

hr {
    display: none;
}

h2 {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--primary-blue);
    letter-spacing: 0.5px;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-tertiary);
}

.x-remove-btn {
    background: var(--error-bg);
    color: var(--text-white);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    margin: 0 3px;
    box-shadow: 0 1px 2px var(--shadow-light);
    outline: none;
    padding: 0;
    vertical-align: middle;
}

.x-remove-btn:hover, .x-remove-btn:focus {
    background: var(--error-bg-dark);
    color: var(--text-white);
    outline: 2px solid var(--error-bg);
}

.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

label {
    min-width: 120px;
    font-weight: 500;
    margin-bottom: 0;
}

input[type='text'], input[type='file'], textarea {
    padding: 8px 10px;
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
}

input[type='file'] {
    background: var(--bg-gray-light);
    font-size: 0.97rem;
}

.dialog-edit-textarea {
    min-height: 60px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
}

button {
    padding: 9px 18px;
    background: var(--primary-blue);
    color: var(--text-white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.15s;
    margin-right: 10px;
}

.generate-line-btn, .play-line-btn {
    background: var(--bg-blue-light);
    color: var(--text-blue);
    border: 1.5px solid var(--border-blue);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    padding: 0;
    box-shadow: 0 1px 2px var(--shadow-light);
    vertical-align: middle;
}

.generate-line-btn:disabled, .play-line-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.generate-line-btn.loading {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.generate-line-btn:hover, .play-line-btn:hover {
    background: var(--bg-blue-lighter);
    color: var(--text-blue-darker);
    border-color: var(--text-blue);
}

button:hover, button:focus {
    background: var(--primary-blue-dark);
    outline: none;
}

.dialog-controls {
    margin-bottom: 10px;
}

#speaker-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#speaker-list li {
    padding: 7px 0;
    border-bottom: 1px solid var(--border-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#speaker-list li:last-child {
    border-bottom: none;
}

pre {
    background: var(--bg-light);
    padding: 12px;
    border-radius: 4px;
    font-size: 0.98rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

audio {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 8px;
}

#zip-archive-link {
    display: inline-block;
    margin-right: 10px;
    color: var(--text-white);
    background: var(--primary-blue);
    padding: 7px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s;
}

#zip-archive-link:hover, #zip-archive-link:focus {
    background: var(--primary-blue-dark);
}

footer {
    text-align: center;
    padding: 20px 0;
    background: var(--header-bg);
    color: var(--text-white);
    margin-top: 40px;
    font-size: 1rem;
    border-top: 3px solid var(--primary-blue);
}

/* Inline Notification */
.notice {
    max-width: 1100px;
    margin: 16px auto 0;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--border-medium);
    background: var(--bg-white);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 2px var(--shadow-light);
}

.notice--info {
    border-color: var(--border-blue);
    background: var(--bg-blue-light);
}

.notice--success {
    border-color: #A7F3D0;
    background: #ECFDF5;
}

.notice--warning {
    border-color: var(--warning-border);
    background: var(--warning-bg);
}

.notice--error {
    border-color: var(--error-bg-dark);
    background: #FEE2E2;
}

.notice__content {
    flex: 1;
}

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

.notice__actions button {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-medium);
    background: var(--bg-white);
    cursor: pointer;
}

.notice__actions .btn-primary {
    background: var(--primary-blue);
    color: var(--text-white);
    border: none;
}

.notice__close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
}

@media (max-width: 900px) {
    .panel-grid {
        flex-direction: column;
        gap: 22px;
    }
    .panel {
        min-width: 0;
    }
}

/* Simple side-by-side layout for speaker management */
.speaker-mgmt-row {
    display: flex;
    gap: 20px;
}

.speaker-mgmt-row .card {
    flex: 1;
    width: 50%;
}

/* Stack on mobile */
@media (max-width: 768px) {
    .speaker-mgmt-row {
        flex-direction: column;
    }
    .speaker-mgmt-row .card {
        width: 100%;
    }
}

.move-up-btn, .move-down-btn {
    background: var(--bg-blue-light);
    color: var(--text-blue);
    border: 1.5px solid var(--border-blue);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    padding: 0;
    box-shadow: 0 1px 2px var(--shadow-light);
    vertical-align: middle;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.move-up-btn:disabled, .move-down-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.move-up-btn:hover:not(:disabled), .move-down-btn:hover:not(:disabled) {
    background: var(--bg-blue-lighter);
    color: var(--text-blue-darker);
    border-color: var(--text-blue);
}

.move-up-btn:focus, .move-down-btn:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

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

.modal-content {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-strong);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: var(--bg-light);
}

.modal-body {
    padding: 20px 24px;
}

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

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-group input[type="range"] {
    width: 100%;
    margin-bottom: 4px;
}

.settings-group span {
    display: inline-block;
    min-width: 40px;
    font-weight: 500;
    color: var(--primary-blue);
    margin-left: 8px;
}

.settings-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
    line-height: 1.3;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-light);
}

.btn-primary, .btn-secondary {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: var(--text-white);
}

.btn-primary:hover {
    background-color: var(--primary-blue-dark);
}

.btn-secondary {
    background-color: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
    background-color: var(--border-light);
}

/* Settings button styling */
.settings-line-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-light);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    margin: 0 2px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.settings-line-btn:hover {
    background-color: var(--primary-blue);
    color: var(--text-white);
    transform: scale(1.05);
}

.settings-line-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
