/* Modern Floating Layout - Blue Theme */
html, body {
    overflow: hidden;
    height: 100%;
}
body {
    background: linear-gradient(135deg, #2c5171 0%, #4682b4 50%, #6a9bc3 100%);
    background-attachment: fixed;
}
/* PWA standalone mode - flow layout (navbar/main/footer move together) */
@media (display-mode: standalone) {
    .app-layout {
        padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
        gap: 8px;
    }
    .navbar {
        position: static !important;
    }
    .main-card {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
    .app-footer {
        position: static !important;
    }
}
html.ios-pwa .app-layout,
body.ios-pwa .app-layout {
    padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 8px;
}
html.ios-pwa .navbar,
body.ios-pwa .navbar {
    position: static !important;
}
html.ios-pwa .main-card,
body.ios-pwa .main-card {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}
html.ios-pwa .app-footer,
body.ios-pwa .app-footer {
    position: static !important;
}
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 12px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;
    position: relative;
}
/* Floating Header */
.navbar {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(70, 130, 180, 0.15);
    padding: 12px 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}
.navbar-brand, .navbar-title {
    font-weight: 700;
    font-size: 18px;
    background: linear-gradient(135deg, #4682b4 0%, #6a9bc3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.navbar-nav .btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.navbar-nav .btn:hover {
    background: rgba(255, 255, 255, 0.8);
}
.navbar-nav .nav-link {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.navbar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.8);
}
/* Main Card Container */
.main-card {
    flex: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(70, 130, 180, 0.12);
    margin-top: calc(78px + env(safe-area-inset-top, 0px));
    margin-bottom: 80px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.6);
}
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
/* Floating Footer */
.app-footer {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(70, 130, 180, 0.15);
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    font-size: 13px;
    color: var(--text-light);
}
.app-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}
.app-footer a:hover {
    color: #4682b4;
}
.footer-separator {
    color: rgba(0, 0, 0, 0.2);
}
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    border-radius: 0;
    min-height: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 0;
}
.chat-controls {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(70, 130, 180, 0.18);
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
}
.drag-handle {
    width: 100%;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: rgba(70, 130, 180, 0.4);
    font-size: 12px;
    margin-bottom: 2px;
    border-radius: 4px;
    transition: background 0.2s;
    user-select: none;
    -webkit-user-select: none;
}
.drag-handle:hover {
    background: rgba(70, 130, 180, 0.1);
    color: rgba(70, 130, 180, 0.7);
}
.drag-handle:active {
    cursor: grabbing;
}
.controls-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.control-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}
.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.record-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 18px;
    background: linear-gradient(135deg, #4682b4 0%, #6a9bc3 100%);
    color: var(--text-inverse);
    box-shadow: 0 6px 20px rgba(70, 130, 180, 0.4);
}
.record-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2c5171 0%, #3a6d96 100%);
}
.record-btn.recording {
    background: var(--error);
    animation: recordPulse 1.5s ease-in-out infinite;
}
@keyframes recordPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(232, 98, 109, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(232, 98, 109, 0.6); }
}
.btn-secondary { background: var(--btn-default); color: var(--text-inverse); }
.btn-success { background: var(--success); color: var(--text-inverse); }
.btn-danger { background: var(--error); color: var(--text-inverse); }
/* Compact message styles */
.message {
    padding: 3px 8px;
    max-width: 90%;
}
.message-header {
    font-size: 10px;
    margin-bottom: 1px;
}
.message-content {
    font-size: 13px;
    line-height: 1.1;
}
.message-meta {
    margin-top: 2px;
    gap: 4px;
}
.meta-badge {
    padding: 1px 4px;
    font-size: 10px;
}
/* Toggle Switch - Vertical compact */
.toggle-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.toggle-switch-track {
    width: 38px;
    height: 20px;
    background: var(--btn-default);
    border-radius: var(--radius-full);
    position: relative;
    transition: background 0.2s ease;
}
.toggle-switch-thumb {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--btn-default);
}
.toggle-switch.active .toggle-switch-track {
    background: linear-gradient(135deg, #4682b4 0%, #6a9bc3 100%);
}
.toggle-switch.active .toggle-switch-thumb {
    transform: translateX(18px);
    color: #4682b4;
}
.toggle-switch:hover .toggle-switch-track {
    opacity: 0.9;
}
.speaker-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #fff;
}
.speaker-0 { background: #14508a; }
.speaker-1 { background: #5b21b6; }
.speaker-2 { background: #065f2c; }
.speaker-3 { background: #b45309; }
.download-transcript-btn {
    margin-top: 3px;
    padding: 2px 8px;
    background: var(--success);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-inverse);
    font-weight: 600;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-fast);
}
.download-transcript-btn:hover {
    background: #097a38;
    transform: translateY(-1px);
}
.message-downloads {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
/* Message action buttons */
.message {
    position: relative;
}
.message-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    gap: 4px;
}
.message:hover .message-actions {
    display: flex;
}
.msg-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(70, 130, 180, 0.1);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #4682b4;
    transition: all 0.2s ease;
}
.msg-action-btn:hover {
    background: rgba(70, 130, 180, 0.2);
}
.msg-action-delete:hover {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}
.msg-action-play.playing {
    background: rgba(70, 130, 180, 0.3);
    color: #4682b4;
}
.msg-action-play.playing:hover {
    background: rgba(70, 130, 180, 0.4);
}
/* Edit mode - maintain card size */
.message.editing {
    max-width: 90%;
    min-width: inherit;
}
.message-edit-container {
    width: 100%;
    min-width: 200px;
}
.message-edit-input {
    width: 100%;
    min-height: 60px;
    max-height: 150px;
    padding: 6px 8px;
    border: 1px solid rgba(70, 130, 180, 0.4);
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.3;
    resize: vertical;
    box-sizing: border-box;
    background: var(--bg-white);
}
.message-edit-input:focus {
    border-color: #4682b4;
    outline: none;
}
.message-edit-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    justify-content: flex-end;
}
.message-edit-actions button {
    padding: 3px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s ease;
}
.edit-save-btn {
    background: linear-gradient(135deg, #4682b4 0%, #6a9bc3 100%);
    color: white;
}
.edit-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(70, 130, 180, 0.3);
}
.edit-cancel-btn {
    background: rgba(70, 130, 180, 0.1);
    color: #4682b4;
}
.edit-cancel-btn:hover {
    background: rgba(70, 130, 180, 0.2);
}
/* Danger button */
.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
}
.sidebar {
    display: none;
}
.sidebar-overlay {
    display: none;
}
/* Responsive */
@media (max-width: 900px) {
    .app-layout {
        padding: 8px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
    }
    .navbar {
        top: calc(8px + env(safe-area-inset-top, 0px));
        left: 8px;
        right: 8px;
        padding: 10px 16px;
        border-radius: 8px;
    }
    .main-card {
        margin-top: calc(74px + env(safe-area-inset-top, 0px));
        margin-bottom: 74px;
        border-radius: 10px;
    }
    .chat-controls {
        right: 12px;
        padding: 5px;
        border-radius: 10px;
    }
    .control-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
        border-radius: 7px;
    }
    .record-btn {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }
    .toggle-switch-track {
        width: 30px;
        height: 16px;
    }
    .toggle-switch-thumb {
        width: 12px;
        height: 12px;
        font-size: 8px;
    }
    .toggle-switch.active .toggle-switch-thumb {
        transform: translateX(14px);
    }
    .controls-buttons {
        gap: 2px;
    }
    .drag-handle {
        height: 12px;
        font-size: 10px;
        margin-bottom: 1px;
    }
    .app-footer {
        bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        left: 8px;
        right: 8px;
        padding: 6px 16px;
        border-radius: 8px;
    }
}
@media (max-width: 600px) {
    .app-layout {
        padding: 6px;
        padding-top: calc(6px + env(safe-area-inset-top, 0px));
    }
    .navbar {
        top: calc(6px + env(safe-area-inset-top, 0px));
        left: 6px;
        right: 6px;
        padding: 8px 12px;
        border-radius: 8px;
    }
    .navbar-brand, .navbar-title {
        font-size: 15px;
    }
    .main-card {
        margin-top: calc(68px + env(safe-area-inset-top, 0px));
        margin-bottom: 60px;
        border-radius: 10px;
    }
    .chat-controls {
        right: 10px;
        padding: 5px;
        border-radius: 10px;
    }
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
    .record-btn {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }
    .toggle-switch-track {
        width: 32px;
        height: 18px;
    }
    .toggle-switch-thumb {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
    .toggle-switch.active .toggle-switch-thumb {
        transform: translateX(14px);
    }
    .controls-buttons {
        gap: 3px;
    }
    .drag-handle {
        height: 14px;
        font-size: 10px;
        margin-bottom: 1px;
    }
    .app-footer {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        left: 6px;
        right: 6px;
        padding: 5px 12px;
        border-radius: 8px;
        font-size: 10px;
        gap: var(--space-2);
    }
    .chat-messages {
        padding: var(--space-2);
    }
    .message {
        max-width: 95%;
        padding: var(--space-2) var(--space-3);
    }
    .message-content {
        font-size: 13px;
    }
}
@media (max-width: 400px) {
    .navbar-title {
        font-size: 13px;
    }
    .nav-link {
        font-size: 11px;
        padding: 4px 8px;
    }
    .main-card {
        border-radius: 8px;
    }
    .control-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
        border-radius: 6px;
    }
    .record-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .toggle-switch-track {
        width: 28px;
        height: 16px;
    }
    .toggle-switch-thumb {
        width: 12px;
        height: 12px;
        font-size: 7px;
    }
    .toggle-switch.active .toggle-switch-thumb {
        transform: translateX(12px);
    }
    .controls-buttons {
        gap: 2px;
    }
    .chat-controls {
        padding: 4px;
        right: 6px;
    }
    .app-footer {
        left: 6px;
        flex-wrap: wrap;
        gap: 6px;
    }
}
/* Action buttons consistency */
.btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}
.control-btn.btn-secondary.active {
    background: var(--primary);
    color: var(--text-inverse);
}
/* ===== Slide Panels ===== */
.panel-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 900;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.panel-backdrop.active { opacity: 1; visibility: visible; }
.slide-panel {
    position: fixed; top: 0; right: 0;
    width: min(480px, 40vw); height: 100vh; height: 100dvh;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.15);
    display: flex; flex-direction: column;
}
.slide-panel.active { transform: translateX(0); }
.slide-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, #4682B4 0%, #365F8A 100%);
    color: #fff;
    font-weight: 700; font-size: 1rem;
    position: sticky; top: 0; z-index: 1; line-height: 1.2;
}
.slide-panel-header i { margin-right: 8px; }
.slide-panel-close {
    background: none; border: none; color: #fff;
    font-size: 1.4rem; cursor: pointer;
    padding: 4px 10px; border-radius: 6px;
    transition: background 0.2s ease; line-height: 1;
}
.slide-panel-close:hover { background: rgba(255, 255, 255, 0.15); }
.slide-panel-body {
    padding: 20px; flex: 1; overflow-y: auto;
}
.panel-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px; padding: 16px; margin-bottom: 16px;
}
.panel-card-title {
    font-size: 15px; font-weight: 700; margin: 0 0 16px 0;
}
.panel-card-title i { color: #4682B4; margin-right: 6px; }
/* Admin theme */
.admin-header {
    background: linear-gradient(135deg, #e57373 0%, #c62828 100%);
}
.admin-stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px; margin-bottom: 12px;
}
.admin-stat {
    text-align: center; padding: 10px 6px;
    background: rgba(0, 0, 0, 0.03); border-radius: 12px;
}
.admin-stat-value {
    display: block; font-size: 20px; font-weight: 900;
    color: var(--primary); line-height: 1.1;
}
.admin-stat-label {
    display: block; font-size: 10px; font-weight: 600;
    color: #94a3b8; margin-top: 4px;
    text-transform: uppercase; letter-spacing: 0.05em;
}
@keyframes spin { to { transform: rotate(360deg); } }
.admin-user-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; background: rgba(0, 0, 0, 0.03);
    border-radius: 12px; margin-bottom: 8px;
    transition: all 0.2s ease;
}
.admin-user-row:hover { background: rgba(70, 130, 180, 0.08); }
.admin-user-row.inactive { opacity: 0.5; }
.admin-user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.admin-user-avatar.role-admin { background: linear-gradient(135deg, #e57373, #ef5350); }
.admin-user-avatar.role-user { background: linear-gradient(135deg, #4682b4, #6a9bc3); }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name {
    font-weight: 700; font-size: 13px;
    display: flex; align-items: center; gap: 6px;
}
.admin-user-name .badge {
    font-size: 8px; padding: 1px 5px; border-radius: 99px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-admin { background: rgba(229, 115, 115, 0.15); color: #c62828; }
.badge-inactive { background: rgba(148, 163, 184, 0.2); color: #64748b; }
.admin-user-meta { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.admin-user-tokens { text-align: right; flex-shrink: 0; }
.admin-user-token-value { font-size: 14px; font-weight: 800; color: var(--primary); }
.admin-user-token-label { font-size: 9px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-user-actions { display: flex; gap: 2px; flex-shrink: 0; }
.admin-action-btn {
    width: 28px; height: 28px; border: none; border-radius: 8px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: #475569; background: transparent;
    transition: all 0.2s ease;
}
.admin-action-btn:hover { transform: scale(1.15); }
.admin-action-btn.btn-edit:hover { background: rgba(255, 183, 77, 0.15); color: #e65100; }
.admin-action-btn.btn-tokens:hover { background: rgba(70, 130, 180, 0.15); color: #4682b4; }
.admin-action-btn.btn-toggle:hover { background: rgba(102, 187, 106, 0.15); color: #2e7d32; }
.admin-action-btn.btn-admin-toggle:hover { background: rgba(229, 115, 115, 0.15); color: #c62828; }
.admin-action-btn.btn-delete:hover { background: rgba(244, 67, 54, 0.15); color: #b71c1c; }
/* Token adjustment modal */
.token-adjust-modal {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 340px; max-width: 90vw;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px); border-radius: 20px;
    z-index: 1200;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
    opacity: 0; visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.token-adjust-modal.active {
    opacity: 1; visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}
@media (max-width: 1400px) {
    .slide-panel { width: min(480px, 50vw); }
}
@media (max-width: 1024px) {
    .slide-panel { width: 60vw; }
}
@media (max-width: 768px) {
    .slide-panel { width: 80vw; }
}
@media (max-width: 640px) {
    .slide-panel { width: 100%; }
}
