/* CRS Design System - Dark Theme */
/* Based on /docs/crs-design-system.md */

/* ===== CSS Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== CSS Variables ===== */
:root {
    /* Background Colors */
    --primary-bg: #0a0a0a;
    --secondary-bg: #141414;
    --surface: #000000;

    /* Border Colors */
    --default-border: #2a2a2a;
    --hover-border: #3a3a3a;
    --focus-border: #ffffff;

    /* Text Colors */
    --primary-text: #ffffff;
    --secondary-text: #cccccc;
    --muted-text: #888888;
    --disabled-text: #666666;
    --placeholder-text: #555555;

    /* Accent Colors */
    --required-field: #ff4444;
    --success: #4caf50;
    --error: #f44336;
    --info: #2196f3;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* ===== Base Styles ===== */
body {
    font-family: var(--font-family);
    background: var(--primary-bg);
    color: var(--primary-text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(180deg, #000000 0%, #1a1a1a 100%);
    border-bottom: 1px solid var(--default-border);
    padding: 40px 20px;
    text-align: center;
    position: relative;
}

.logo img {
    height: 60px;
    width: auto;
}

.tagline {
    font-size: 14px;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 300;
    margin-top: 10px;
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--default-border);
    color: var(--primary-text);
    border: 1px solid var(--hover-border);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: var(--hover-border);
    border-color: #4a4a4a;
}

/* ===== Container ===== */
.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Card / Section ===== */
.card,
.upload-section,
.login-container {
    background: var(--secondary-bg);
    border: 1px solid var(--default-border);
    border-radius: 4px;
    padding: 40px;
    margin-top: 40px;
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary-text);
}

.section-subtitle {
    font-size: 14px;
    color: var(--muted-text);
    margin-bottom: 30px;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--secondary-text);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.required {
    color: var(--required-field);
    margin-left: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--primary-bg);
    border: 1px solid var(--default-border);
    border-radius: 2px;
    font-size: 15px;
    color: var(--primary-text);
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--focus-border);
    background: var(--surface);
}

input::placeholder,
textarea::placeholder {
    color: var(--placeholder-text);
}

/* Date Input Calendar Icon */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Select Dropdown */
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23888888' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

select option {
    background: var(--primary-bg);
    color: var(--primary-text);
}

/* Textarea */
textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== File Input ===== */
.file-drop-zone {
    width: 100%;
    padding: 40px 20px;
    background: var(--primary-bg);
    border: 2px dashed var(--default-border);
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: var(--focus-border);
    background: var(--surface);
}

.file-drop-zone p {
    color: var(--muted-text);
    font-size: 14px;
    margin: 10px 0;
}

.file-drop-zone .icon {
    font-size: 48px;
    color: var(--muted-text);
    margin-bottom: 10px;
}

.file-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--disabled-text);
}

/* ===== Buttons ===== */
.btn-primary,
.submit-btn {
    width: 100%;
    padding: 18px;
    background: var(--primary-text);
    color: var(--surface);
    border: none;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled),
.submit-btn:hover:not(:disabled) {
    background: #e0e0e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-primary:disabled,
.submit-btn:disabled {
    background: var(--default-border);
    color: var(--disabled-text);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--default-border);
    color: var(--secondary-text);
    padding: 12px 24px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: var(--hover-border);
    color: var(--primary-text);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 12px 24px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: var(--error);
    color: var(--surface);
}

.remove-file-btn {
    background: transparent;
    border: 1px solid var(--default-border);
    color: var(--muted-text);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.remove-file-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

/* ===== File List ===== */
.file-list {
    margin-top: 20px;
}

.file-item {
    background: var(--primary-bg);
    border: 1px solid var(--default-border);
    border-radius: 2px;
    padding: 15px;
    margin-bottom: 10px;
}

.file-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.file-item-name {
    font-size: 14px;
    color: var(--primary-text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
}

.file-item-size {
    font-size: 12px;
    color: var(--muted-text);
    margin-right: 10px;
}

.file-item-speed {
    font-size: 12px;
    color: var(--success);
    margin-right: 10px;
    min-width: 80px;
    text-align: right;
}

.file-item-status {
    font-size: 12px;
    color: var(--muted-text);
    min-width: 80px;
    text-align: right;
}

.file-item-status.completed {
    color: var(--success);
}

.file-item-status.error {
    color: var(--error);
}

.file-item-status.uploading {
    color: var(--info);
}

/* ===== Progress Bar ===== */
.file-progress {
    width: 100%;
    height: 3px;
    background: var(--default-border);
    border-radius: 2px;
    overflow: hidden;
}

.file-progress-fill {
    height: 100%;
    background: var(--primary-text);
    transition: width 0.3s ease;
    width: 0%;
}

/* ===== Messages ===== */
.message {
    padding: 16px 20px;
    margin-top: 20px;
    border-radius: 2px;
    font-size: 14px;
    border-left: 3px solid;
    display: none;
}

.message.show {
    display: block;
}

.message.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
    border-color: var(--success);
}

.message.error {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error);
    border-color: var(--error);
}

.message.info {
    background: rgba(33, 150, 243, 0.1);
    color: var(--info);
    border-color: var(--info);
}

/* ===== Password Toggle ===== */
.password-toggle {
    position: relative;
}

.password-toggle input {
    padding-right: 60px;
}

.password-toggle button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted-text);
    cursor: pointer;
    padding: 8px;
    font-size: 14px;
    transition: color 0.3s ease;
}

.password-toggle button:hover {
    color: var(--primary-text);
}

/* ===== Password Requirements ===== */
.password-requirements {
    background: var(--primary-bg);
    border: 1px solid var(--default-border);
    border-radius: 2px;
    padding: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted-text);
}

.password-requirements strong {
    color: var(--secondary-text);
}

.password-requirements ul {
    margin-left: 20px;
    margin-top: 8px;
}

.password-requirements li {
    margin-bottom: 4px;
}

/* ===== New Password Section (Hidden by default) ===== */
.new-password-section {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--default-border);
}

.new-password-section.show {
    display: block;
}

/* ===== Navigation ===== */
.nav-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

.nav-links a {
    color: var(--muted-text);
    text-decoration: none;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 20px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-text);
    background: var(--default-border);
}

/* ===== Media List ===== */
.media-list {
    margin-top: 20px;
}

.media-list-item {
    display: flex;
    align-items: center;
    background: var(--primary-bg);
    border: 1px solid var(--default-border);
    border-radius: 4px;
    padding: 16px 20px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.media-list-item:hover {
    border-color: var(--hover-border);
    background: var(--secondary-bg);
}

.media-list-icon {
    font-size: 24px;
    margin-right: 16px;
    opacity: 0.7;
}

.media-list-content {
    flex: 1;
    min-width: 0;
}

.media-list-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.media-list-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--primary-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-list-type {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 2px;
    background: var(--default-border);
    color: var(--secondary-text);
}

.media-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 13px;
    color: var(--muted-text);
}

.media-list-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.media-list-meta-label {
    color: var(--disabled-text);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.media-list-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.media-list-tag {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--surface);
    border: 1px solid var(--default-border);
    border-radius: 2px;
    color: var(--secondary-text);
}

.media-list-actions {
    margin-left: 16px;
    display: flex;
    gap: 8px;
}

.media-list-view-btn,
.media-list-download-btn {
    background: transparent;
    border: 1px solid var(--default-border);
    color: var(--secondary-text);
    padding: 8px 16px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.media-list-view-btn:hover,
.media-list-download-btn:hover {
    border-color: var(--primary-text);
    color: var(--primary-text);
}

.media-list-delete-btn {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 8px 16px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.media-list-delete-btn:hover {
    background: var(--error);
    color: var(--surface);
}

/* Legacy grid styles (kept for backwards compatibility) */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.media-item {
    background: var(--primary-bg);
    border: 1px solid var(--default-border);
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.media-item:hover {
    border-color: var(--hover-border);
    transform: translateY(-2px);
}

.media-item-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--surface);
}

.media-item-info {
    padding: 12px;
}

.media-item-name {
    font-size: 14px;
    color: var(--primary-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.media-item-meta {
    font-size: 12px;
    color: var(--muted-text);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--secondary-bg);
    border: 1px solid var(--default-border);
    border-radius: 4px;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.filter-bar label {
    font-size: 11px;
    margin-bottom: 6px;
}

.filter-bar input,
.filter-bar select {
    padding: 10px 12px;
    font-size: 14px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted-text);
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--secondary-text);
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Loading Spinner ===== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--default-border);
    border-top-color: var(--primary-text);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--disabled-text);
    font-size: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .card,
    .upload-section,
    .login-container {
        padding: 30px 20px;
    }

    .header {
        padding: 30px 20px;
    }

    .logo img {
        height: 50px;
    }

    .section-title {
        font-size: 20px;
    }

    .logout-btn {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .form-group {
        width: 100%;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .media-list-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }

    .media-list-icon {
        margin-bottom: 10px;
        margin-right: 0;
    }

    .media-list-content {
        width: 100%;
    }

    .media-list-meta {
        flex-direction: column;
        gap: 8px;
    }

    .media-list-actions {
        margin-left: 0;
        margin-top: 12px;
        width: 100%;
    }

    .media-list-download-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .card,
    .upload-section,
    .login-container {
        padding: 24px 16px;
        margin-top: 20px;
    }

    .logo img {
        height: 40px;
    }

    .nav-links {
        flex-direction: column;
        gap: 10px;
    }

    .nav-links a {
        display: block;
        text-align: center;
    }
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--secondary-bg);
    border: 1px solid var(--default-border);
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 500;
    color: var(--primary-text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted-text);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--primary-text);
}

.modal-body {
    padding: 24px;
}

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

/* ===== Media Detail Modal ===== */
.media-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.media-detail-row {
    display: flex;
    gap: 16px;
}

.media-detail-label {
    color: var(--muted-text);
    font-size: 14px;
    min-width: 100px;
    flex-shrink: 0;
}

.media-detail-value {
    color: var(--primary-text);
    font-size: 14px;
    word-break: break-word;
}

.media-detail-description {
    flex-direction: column;
    gap: 8px;
}

.media-detail-description .media-detail-value {
    white-space: pre-wrap;
    line-height: 1.6;
}

.media-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.media-detail-tag {
    background: var(--default-border);
    color: var(--secondary-text);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
}

/* Make list items clickable */
.media-list-item {
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.media-list-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--hover-border);
}

@media (max-width: 480px) {
    .modal-content {
        max-height: 95vh;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }

    .media-detail-row {
        flex-direction: column;
        gap: 4px;
    }

    .media-detail-label {
        min-width: auto;
    }
}

/* ===== Bulk Action Bar ===== */
.bulk-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--default-border);
    border-radius: 4px;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.bulk-action-info {
    color: var(--secondary-text);
    font-size: 14px;
    font-weight: 500;
}

.bulk-action-info span {
    color: var(--primary-text);
    font-weight: 600;
}

.bulk-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
}

/* ===== Selection Checkbox ===== */
.media-list-checkbox {
    /* Reset default appearance for cross-browser styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    width: 18px;
    height: 18px;
    margin-right: 12px;
    flex-shrink: 0;
    cursor: pointer;

    /* Custom checkbox styling */
    background: var(--primary-bg);
    border: 2px solid var(--muted-text);
    border-radius: 3px;
    position: relative;
    transition: all 0.2s ease;
}

.media-list-checkbox:hover {
    border-color: var(--primary-text);
}

.media-list-checkbox:checked {
    background: var(--primary-text);
    border-color: var(--primary-text);
}

/* Checkmark for checked state */
.media-list-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid var(--surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Selected state for media list items */
.media-list-item.selected {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--hover-border);
}

.media-list-item.selected:hover {
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 768px) {
    .bulk-action-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .bulk-action-buttons {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .bulk-action-buttons {
        flex-direction: column;
        width: 100%;
    }

    .bulk-action-buttons button {
        width: 100%;
    }
}
