/* Base Styles */
* { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; box-sizing: border-box; }
body { margin: 0; padding: 20px; background: #f7f7f8; color: #111; }

.container {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 0 auto;
}

/* Page-specific Container Overrides */
.page-login .container { max-width: 400px; margin: 50px auto; }
.page-tv .container { max-width: 800px; }
.page-channels .container { max-width: 1000px; }
.page-data { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }
.page-data .container { max-width: 1200px; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; padding: 0; }

/* Login Page Elements (.page-login) */
.page-login h1 { margin-top: 0; text-align: center; }
.page-login .form-group { margin-bottom: 15px; }
.page-login label { display: block; margin-bottom: 5px; }
.page-login input[type="text"], .page-login input[type="password"] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; box-sizing: border-box; }
.page-login button { width: 100%; padding: 10px; background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
.page-login button:hover { background: #0056b3; }
.error { background: #ffe8e8; border: 1px solid #ffb3b3; padding: 10px; border-radius: 5px; margin-top: 15px; color: #d00; text-align: center; }

/* TV Dashboard (.page-tv) */
.header-bar { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 20px; }
.page-tv h1, .page-channels h1 { margin-top: 0; margin-bottom: 0; }
.logout-btn { background: #dc3545; color: white; padding: 8px 15px; text-decoration: none; border-radius: 5px; }
.logout-btn:hover { background: #c82333; }
.menu-buttons { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.btn { padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; text-decoration: none; display: inline-block; }
.btn:hover { background: #0056b3; }
.page-tv button[type="submit"] { background: #28a745; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 16px; }
.page-tv button[type="submit"]:hover { background: #218838; }
.output { background: #2d2d2d; color: #00ff00; border: 1px solid #111; padding: 15px; margin-top: 20px; border-radius: 5px; white-space: pre-wrap; word-wrap: break-word; max-height: 400px; overflow-y: auto; font-family: monospace; }

/* Channels (.page-channels) */
.back-btn { background: #6c757d; color: white; padding: 8px 15px; text-decoration: none; border-radius: 5px; border: none; font-size: 0.95em; cursor: pointer; transition: all 0.3s ease; }
.back-btn:hover { background: #5a6268; transform: none; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 15px; margin-top: 20px; }
.items a { display: flex; align-items: center; justify-content: center; background: #fdfdfd; border: 1px solid #ddd; padding: 15px; border-radius: 8px; transition: transform 0.2s, box-shadow 0.2s; text-decoration: none; }
.items a:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.items img { max-width: 100%; height: auto; max-height: 60px; }

/* Data (.page-data) */
.page-data .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center; }
.page-data .header h1 { font-size: 2em; margin-bottom: 10px; margin-top: 0; }
.page-data .header p { font-size: 0.95em; opacity: 0.9; margin: 0; }
.controls { padding: 20px 30px; background: #f8f9fa; border-bottom: 1px solid #e9ecef; display: flex; gap: 15px; flex-wrap: wrap; align-items: center; }
.search-box { flex: 1; min-width: 250px; }
.search-box input { width: 100%; padding: 10px 15px; border: 1px solid #dee2e6; border-radius: 6px; font-size: 0.95em; }
.search-box input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); }
.refresh-btn { padding: 10px 20px; background: #667eea; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.95em; transition: all 0.3s ease; }
.refresh-btn:hover { background: #5568d3; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3); }
.refresh-btn:active { transform: translateY(0); }
.page-data .back-btn { padding: 10px 20px; }
.page-data .back-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3); }
.page-data .back-btn:active { transform: translateY(0); }
.content { padding: 30px; max-height: 70vh; overflow-y: auto; }
.file-list { display: flex; flex-direction: column; gap: 12px; }
.file-item { background: white; border: 1px solid #e9ecef; border-radius: 8px; padding: 15px; display: flex; justify-content: space-between; align-items: center; transition: all 0.3s ease; }
.file-item:hover { background: #f8f9fa; border-color: #667eea; box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1); }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; color: #212529; margin-bottom: 6px; word-break: break-word; }
.file-meta { display: flex; gap: 20px; font-size: 0.85em; color: #6c757d; }
.file-size, .file-date { display: flex; align-items: center; gap: 5px; }
.file-actions { display: flex; gap: 10px; margin-left: 15px; }
.file-btn { padding: 8px 12px; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.9em; transition: all 0.3s ease; white-space: nowrap; font-weight: 500; }
.download-btn { background: #28a745; }
.download-btn:hover { background: #218838; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3); }
.rename-btn { background: #ff8c00; }
.rename-btn:hover { background: #e67e00; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 140, 0, 0.3); }
.delete-btn { background: #dc3545; }
.delete-btn:hover { background: #c82333; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3); }
.file-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.4); animation: fadeIn 0.3s ease; }
.modal.show { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content { background-color: white; margin: 10% auto; padding: 20px; border-radius: 8px; max-width: 500px; box-shadow: 0 4px 20px rgba(0,0,0,0.3); animation: slideDown 0.3s ease; }
@keyframes slideDown { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { font-size: 1.3em; font-weight: bold; margin-bottom: 15px; color: #212529; }
.modal-body { margin-bottom: 20px; }
.modal-body input { width: 100%; padding: 10px; border: 1px solid #dee2e6; border-radius: 6px; font-size: 0.95em; box-sizing: border-box; }
.modal-body input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); }
.modal-body p { margin: 10px 0; color: #6c757d; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; }
.modal-footer button { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-size: 0.95em; transition: all 0.3s ease; }
.modal-confirm { background: #dc3545; color: white; }
.modal-confirm:hover { background: #c82333; }
.modal-cancel { background: #6c757d; color: white; }
.modal-cancel:hover { background: #5a6268; }
.progress-bar-container { width: 100px; height: 4px; background: #e9ecef; border-radius: 2px; overflow: hidden; margin-left: 10px; }
.progress-bar { height: 100%; background: #28a745; width: 0%; transition: width 0.3s ease; }
.loading { text-align: center; padding: 40px; color: #6c757d; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid #667eea; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.page-data .error { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; padding: 15px; border-radius: 6px; margin-bottom: 20px; text-align: left; }
.info { background: #d1ecf1; border: 1px solid #bee5eb; color: #0c5460; padding: 15px; border-radius: 6px; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid #e9ecef; }
.stat-box { background: #f8f9fa; padding: 15px; border-radius: 6px; text-align: center; }
.stat-value { font-size: 1.8em; font-weight: 700; color: #667eea; }
.stat-label { font-size: 0.85em; color: #6c757d; margin-top: 5px; }
.empty-message { text-align: center; color: #6c757d; padding: 40px 20px; }
@media (max-width: 768px) {
    .controls { flex-direction: column; }
    .search-box { min-width: 100%; }
    .file-item { flex-direction: column; align-items: flex-start; }
    .file-actions { width: 100%; margin-left: 0; margin-top: 10px; }
    .download-btn { flex: 1; text-align: center; }
}

/* Modal from record_click_handler.html (styled overlay) */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-overlay .modal-content { background: white; padding: 25px 30px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); width: 100%; max-width: 400px; transform: translateY(20px) scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); text-align: center; margin: 0; animation: none; }
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
.modal-title { margin: 0 0 15px 0; font-size: 1.25rem; color: #111; font-weight: 600; }
.modal-description { margin: 0 0 20px 0; color: #555; font-size: 0.95rem; line-height: 1.5; }
.modal-input-group { margin-bottom: 25px; text-align: left; }
.modal-input-group label { display: block; margin-bottom: 8px; color: #444; font-size: 0.9rem; font-weight: 500; }
.modal-input { width: 100%; padding: 10px 15px; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; }
.modal-input:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.15); }
.modal-buttons { display: flex; justify-content: flex-end; gap: 12px; }
.modal-btn { padding: 10px 20px; border: none; border-radius: 6px; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: background-color 0.2s, transform 0.1s; }
.modal-btn:active { transform: translateY(1px); }
.modal-btn-cancel { background: #f1f3f5; color: #495057; }
.modal-btn-cancel:hover { background: #e2e6ea; }
.modal-btn-confirm { background: #007bff; color: white; }
.modal-btn-confirm:hover { background: #0069d9; }
.toast-notification { position: fixed; bottom: 20px; right: 20px; padding: 15px 25px; color: white; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); font-size: 0.95rem; font-weight: 500; z-index: 1001; transform: translateY(100px); opacity: 0; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease; display: flex; align-items: center; gap: 10px; }
.toast-notification.show { transform: translateY(0); opacity: 1; }
.toast-success { background-color: #28a745; }
.toast-error { background-color: #dc3545; }
