/* 1. Global Resets & Defaults */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans TC', sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Header Styles */
.header {
    background-color: #333;
    color: white;
    padding: 10px 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.menu a {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    padding: 2px 6px;
}
.menu a:hover {
    text-decoration: underline;
}
.hamburger {
    display: none;
    font-size: 24px;
    cursor: pointer;
}
.menu.right {
    margin-left: auto;
}
@media (max-width: 200px) {
    .menu {
        display: none;
        width: 100%;
        flex-direction: column;
        background-color: #333;
        margin-top: 10px;
    }
    .menu.active {
        display: flex;
    }
    .hamburger {
        display: block;
        color: white;
    }
}

/* 2. Layout & Containers */
.container, .page-center-container {
    width: 100%;
    padding: 5px;
    background-color: #ffffff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.07);
    overflow-x: auto;
}

.heading-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px; /* Maintained for spacing if not space-between */
    margin-bottom: 20px;
}

.heading-with-button h2 {
    margin: 0;
}

.form-container {
    max-width: 500px;
    margin: 40px auto;
}

.card {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    margin-bottom: 20px;
}

.content {
    padding: 5px;
}

/* 3. Typography */
h1, h2, h3, h4, h5, h6 {
    color: #0056b3;
    margin-bottom: 1rem;
    line-height: 1.3;
}

h1 { font-size: 2.2em; border-bottom: 2px solid #0056b3; padding-bottom: 10px; }
h2 { font-size: 1.8em; border-bottom: 1px solid #eee; padding-bottom: 8px; }
h3 { font-size: 1.4em; }
h4 { font-size: 1.1em; }

.page-title {
    font-size: 2.5em;
    margin-bottom: 25px;
}

.highlight {
    background-color: #fff3cd;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
    color: #856404;
}

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

.query-time {
    margin-top: 10px;
    color: gray;
}

.history-title {
    cursor: pointer;
    color: blue;
    text-decoration: underline;
}

/* 4. Tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
    background-color: #fff;
}

th, td {
    border: 1px solid #dee2e6;
    padding: 12px 15px;
    text-align: left;
    vertical-align: top;
}

th {
    background-color: #f2f2f2;
    color: #0056b3;
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f1f1f1;
}

th.sortable {
    cursor: pointer;
}

th.sortable:hover {
    background-color: #e9ecef;
}

th .sort-arrow {
    font-size: 0.8em;
    margin-left: 5px;
}

/* 5. Forms & Inputs */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: .5rem;
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-weight: normal;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.2);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

/* Form Layouts */
.inline-form, .search-form, .add-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.inline-form label, .search-form label, .add-form label {
    margin-bottom: 0;
    white-space: nowrap;
}

.inline-form input[type="text"],
.inline-form input[type="password"],
.inline-form input[type="email"],
.inline-form input[type="number"],
.inline-form input[type="date"] {
    flex-grow: 1;
    flex-basis: 150px;
    width: auto;
}

.inline-form select {
    width: auto;
}

.generate-code-form label {
    display: inline-block;
    margin-right: 10px;
    white-space: nowrap;
}

.generate-code-form input[type="number"],
.generate-code-form input[type="date"],
.generate-code-form input[type="text"] {
    width: auto; /* Override 100% width */
    display: inline-block;
    margin-right: 20px; /* Space between inputs */
}

.field-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.field-group label {
    flex-basis: 120px;
    text-align: right;
    margin-bottom: 0;
}
.field-group input, .field-group textarea {
    flex-grow: 1;
}

/* 6. Buttons */
.btn, button {
    display: inline-block;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    text-align: center;
    vertical-align: middle;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: auto;
}

.btn:hover, button:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.btn:active, button:active {
    transform: translateY(0);
}

.btn:disabled, button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.btn-success { background-color: #28a745; }
.btn-success:hover { background-color: #218838; }

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

.delete-button:hover {
    background-color: #C70039 !important;
}

.btn-large {
    padding: 12px 25px;
    font-size: 1.1em;
}

/* 7. Messages & Alerts */
.message, .error, .success, .info, .error-message {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
    border: 1px solid transparent;
}

.message:empty, .error:empty, .success:empty, .info:empty, .error-message:empty {
    display: none;
}

.error, .error-message {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* 8. Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 25px;
    list-style: none;
}

.pagination a, .pagination strong, .pagination button {
    margin: 0 4px;
    padding: 8px 14px;
    text-decoration: none;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #007bff;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.pagination a:hover, .pagination button:hover {
    background-color: #e9ecef;
}

.pagination strong, .pagination button.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
    font-weight: bold;
}

/* 9. Tabs */
.tabs {
    margin-top: 20px;
}

.tab-buttons {
    display: flex;
    border-bottom: 2px solid #0056b3;
    margin-bottom: 0;
    list-style: none;
}

.tab-button {
    padding: 12px 20px;
    border: 1px solid #ccc;
    border-bottom: none;
    cursor: pointer;
    margin-right: 5px;
    background: #f0f0f0;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.tab-button.active {
    background: white;
    border-color: #0056b3;
    font-weight: bold;
    color: #0056b3;
    border-bottom: 2px solid white;
    margin-bottom: -2px;
}

.tab-content {
    display: none;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-top: none;
    background-color: #fff;
    border-radius: 0 0 8px 8px;
}

.tab-content.active {
    display: block;
}

/* Display & Visibility Helpers */
.d-none,
.hidden-qrcode,
.qrcode-container.hidden-qrcode,
.qrcode-column,
.edit-mode {
    display: none;
}

.d-inline { display: inline; }
.d-inline-block { display: inline-block; }

/* In-place Edit for Tables */
tr.is-editing .display-mode {
    display: none;
}
tr.is-editing .edit-mode {
    display: block; /* Use block to show the edit form */
}
.edit-mode div {
    margin-bottom: 5px;
}
.edit-mode label {
    display: inline-block;
    width: 80px;
    text-align: right;
    margin-right: 5px;
    vertical-align: top;
}

/* Specific Input Widths for yt_list_manage.php */
form input[type="text"],
form input[type="number"],
.edit-mode input[type="text"],
.edit-mode input[type="number"] {
    width: 120px;
    max-width: 100%;
}
.search-form input {
    width: auto;
    min-width: 80px;
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    background-color: #e0e0e0;
    border-radius: 5px;
    margin-top: 20px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 20px;
    background-color: #28a745;
    border-radius: 5px;
    text-align: center;
    line-height: 20px;
    color: white;
    transition: width 0.5s ease;
}

/* Video Player */
.video-wrapper {
    position: relative;
    width: 100%;
	height: 70%;
    #padding-bottom: 56.25%; /* 16:9 */
	margin: 0 auto;
    margin-top: 20px;
    display: none;
    background: #000;
}

.video-wrapper iframe {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 0;
}

/* View Switcher */
.view-switcher {
    margin-bottom: 20px;
    text-align: center;
}

.view-switcher a {
    padding: 8px 15px;
    border: 1px solid #0056b3;
    color: #0056b3;
    border-radius: 5px;
    margin-right: 10px;
}

.view-switcher a.active {
    background-color: #0056b3;
    color: white;
}

/* Comparison Results */
.result-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid #eee;
    background-color: #f9f9f9;
}

.result-item .thumbnail {
    width: 120px;
    height: 90px;
    margin-right: 15px;
    flex-shrink: 0;
    object-fit: cover;
}

.result-item .details { flex-grow: 1; }
.result-item h3 { margin-top: 0; margin-bottom: 5px; }
.result-item p { margin: 0 0 5px 0; font-size: 0.95em; }
.result-item .action-buttons { margin-top: 10px; }

/* Status Indicators */
.status-mismatch { color: #fd7e14; font-weight: bold; }
.status-match { color: #28a745; font-weight: bold; }
.status-new { color: #007bff; font-weight: bold; }
.not-found { color: #dc3545; font-weight: bold; }

/* Per Page Controls */
.per-page-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 11. Global Spacing */
body > *:not(.header) {
    padding-left: 20px;
    padding-right: 20px;
}

@media (max-width: 768px) {
    body > *:not(.header) {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* 12. Media Queries */
@media (max-width: 768px) {
    .container, .card {
        padding: 15px;
    }

    h1 { font-size: 1.8em; }
    h2 { font-size: 1.5em; }

    .inline-form, .search-form, .add-form {
        flex-direction: column;
        align-items: stretch;
    }

    .result-item {
        flex-direction: column;
    }

    .result-item .thumbnail {
        margin-bottom: 10px;
    }

    /* Table RWD adjustments */
    table th, table td {
        padding: 8px 10px; /* Smaller padding */
        font-size: 0.9em; /* Smaller font size */
    }
}
