/* ==========================================================================
   Video Downloader & Server — Styles
   ========================================================================== */

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

:root {
    --bg:        #0f0f13;
    --surface:   #1a1a24;
    --surface2:  #24243a;
    --border:    #2e2e4a;
    --text:      #e0e0f0;
    --text-dim:  #8888aa;
    --primary:   #6c5ce7;
    --primary-h: #7f70f0;
    --success:   #00b894;
    --error:     #e74c3c;
    --warning:   #fdcb6e;
    --info:      #74b9ff;
    --radius:    10px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary-h); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Navbar --- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-h);
}

.nav-links { display: flex; gap: 1rem; }

.nav-link {
    padding: .4rem 1rem;
    border-radius: 6px;
    font-size: .95rem;
    transition: background .2s;
    color: var(--text-dim);
}
.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }

/* --- Container --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 2rem; margin-bottom: .25rem; }
.page-header p  { color: var(--text-dim); }

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 1.25rem; margin-bottom: 1rem; }

/* --- Forms --- */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.form-group.flex-grow { flex: 1; min-width: 250px; }

label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .04em;
}

input[type="text"],
input[type="url"],
select {
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: .95rem;
    transition: border-color .2s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,.25);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-h); }

.btn-sm {
    padding: .3rem .7rem;
    font-size: .8rem;
    border-radius: 5px;
}
.btn-play   { background: var(--success); color: #fff; }
.btn-play:hover   { background: #00d2a0; }
.btn-download { background: var(--info); color: #fff; }
.btn-download:hover { background: #5a9ff0; }
.btn-watch { background: var(--primary); color: #fff; }
.btn-watch:hover { background: var(--primary-h); text-decoration: none; }
.btn-share { background: var(--success); color: #fff; }
.btn-share:hover { background: #00d2a0; }
.btn-delete { background: var(--error); color: #fff; }
.btn-delete:hover { background: #ff6b5a; }

/* --- Status Messages --- */
.status-message {
    margin-top: 1rem;
    padding: .7rem 1rem;
    border-radius: 6px;
    font-size: .9rem;
    word-break: break-all;
}
.status-info  { background: rgba(116,185,255,.15); color: var(--info); }
.status-success { background: rgba(0,184,148,.15); color: var(--success); }
.status-error   { background: rgba(231,76,60,.15); color: var(--error); }

/* --- Site Tags --- */
.site-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: .75rem 0;
}
.site-tag {
    background: var(--surface2);
    padding: .25rem .65rem;
    border-radius: 20px;
    font-size: .8rem;
    color: var(--text-dim);
}

.info-note { margin-top: .75rem; color: var(--text-dim); font-size: .9rem; }
.info-note code {
    background: var(--surface2);
    padding: .15rem .4rem;
    border-radius: 4px;
}

/* --- Video Grid --- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.video-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.video-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-info { padding: .75rem 1rem; }
.video-title {
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: .4rem;
}
.video-meta {
    display: flex;
    gap: 1rem;
    font-size: .8rem;
    color: var(--text-dim);
    margin-bottom: .6rem;
}
.video-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

/* --- Video Table --- */
.video-table { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: .6rem .8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    font-size: .8rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: .04em;
}
.video-link {
    color: var(--primary-h);
    max-width: 300px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Tasks --- */
.tasks-list { display: flex; flex-direction: column; gap: 1rem; }

.task-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.task-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
}
.task-status {
    font-size: .85rem;
    font-weight: 600;
    padding: .2rem .6rem;
    border-radius: 20px;
}
.status-downloading { background: rgba(116,185,255,.2); color: var(--info); }
.status-completed   { background: rgba(0,184,148,.2); color: var(--success); }
.status-error       { background: rgba(231,76,60,.2); color: var(--error); }

.task-id {
    font-family: monospace;
    font-size: .8rem;
    color: var(--text-dim);
}
.task-url {
    font-size: .85rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: .5rem;
}

.task-progress {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-h));
    border-radius: 4px;
    transition: width .3s;
}
.progress-text { font-size: .8rem; color: var(--text-dim); min-width: 45px; }

.task-meta {
    display: flex;
    gap: 1.5rem;
    font-size: .8rem;
    color: var(--text-dim);
    flex-wrap: wrap;
}
.task-error {
    margin-top: .5rem;
    padding: .5rem .75rem;
    background: rgba(231,76,60,.1);
    border-radius: 6px;
    color: var(--error);
    font-size: .85rem;
}

/* --- Info Grid --- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.info-item {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.info-label {
    font-size: .8rem;
    color: var(--text-dim);
    text-transform: uppercase;
}
.info-value { font-size: 1rem; font-weight: 600; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
}
.empty-state p { font-size: 1.1rem; }

/* --- Modal --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 64px rgba(0,0,0,.6);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1rem; overflow-y: auto; }

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-dim);
    font-size: .85rem;
    border-top: 1px solid var(--border);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .container { padding: 1rem; }
    .form-row { flex-direction: column; }
    .form-group.flex-grow { min-width: 100%; }
    .video-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Minimal Layout (Watch Page) --- */
.minimal-body {
    background: #000;
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.minimal-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- Watch Page --- */
.watch-container {
    max-width: 1200px;
    margin: 0 auto;
}

.video-wrapper {
    width: 100%;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.video-wrapper video {
    width: 100%;
    max-height: 75vh;
    display: block;
    background: #000;
}

.video-details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.video-title {
    font-size: 1.4rem;
    margin-bottom: .75rem;
    word-break: break-all;
}

.video-meta-row {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .95rem;
}

.meta-label {
    color: var(--text-dim);
    font-weight: 600;
}

.meta-value {
    color: var(--text);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-download {
    background: var(--info);
    color: #fff;
}
.btn-download:hover {
    background: #5a9ff0;
}

.btn-share {
    background: var(--success);
    color: #fff;
}
.btn-share:hover {
    background: #00d2a0;
}

.share-toast {
    margin-top: 1rem;
    padding: .75rem 1rem;
    background: rgba(0,184,148,.15);
    border: 1px solid var(--success);
    border-radius: 6px;
    color: var(--success);
    font-size: .9rem;
    text-align: center;
}
