/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background: #f8fafc;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 48px;
    height: 48px;
}

header h1 {
    font-size: 1.8rem;
    color: var(--text-primary);
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Info Cards */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.card-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.card-content {
    flex: 1;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Sections */
.carousel-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    margin: 0;
    color: var(--text-primary);
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 8px;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Cards Container */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    animation: fadeIn 0.5s ease;
}

.carousel-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.carousel-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.carousel-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.carousel-card:hover::before {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.125rem;
}

.card-media-type {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.media-video {
    background: #dbeafe;
    color: #1e40af;
}

.media-image {
    background: #dcfce7;
    color: #166534;
}

.card-merchant {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.card-filename {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    word-break: break-all;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-meta-icon {
    font-size: 1rem;
}

.play-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 12px;
    font-weight: 600;
    color: var(--primary-color);
}

.card-notes {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--warning-color);
}

/* Loop Duration Info */
.loop-duration-info {
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.loop-duration-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.loop-duration-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
}


/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.125rem;
}


/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

th,
td {
    padding: 1rem;
    text-align: center;
}

th {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Media type row colors */
.row-video {
    background-color: #f0fdf4 !important;
    /* Light green for videos */
}

.row-image {
    background-color: #fefce8 !important;
    /* Light yellow for images */
}

.row-video:hover,
.row-image:hover {
    filter: brightness(0.95);
}

tbody tr:last-child {
    border-bottom: none;
}

td.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.9375rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 350px;
    border-left: 4px solid var(--primary-color);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left-color: var(--success-color);
    color: var(--success-color);
}

.notification-error {
    border-left-color: var(--danger-color);
    color: var(--danger-color);
}

.notification-warning {
    border-left-color: var(--warning-color);
    color: var(--warning-color);
}

/* Confirmation Modal */
.confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease;
}

.confirm-modal {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.confirm-modal-content {
    text-align: center;
    margin-bottom: 2rem;
}

.confirm-modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.confirm-modal-message {
    font-size: 1.125rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.confirm-modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirm-modal-actions .btn {
    flex: 1;
    max-width: 150px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .info-cards {
        grid-template-columns: 1fr;
    }

    .carousel-section {
        padding: 1rem;
    }

    th,
    td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
}

/* Screen Switcher */

.screen-switcher h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.screen-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.screen-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.screen-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.screen-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
}


.screen-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.screen-btn.active .screen-name {
    color: white;
}

/* Adjust screen icon size */

.screen-btn {
    min-width: 100px;
    padding: 0.75rem 1rem;
}

.screen-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Make screen switcher smaller */
.screen-btn {
    min-width: unset !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 8px !important;
    gap: 0.25rem !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.screen-icon {
    font-size: 1.25rem !important;
    margin-bottom: 0 !important;
}

.screen-name {
    font-size: 0.8rem !important;
}

/* Improved Screen Switcher - Horizontal Layout */

.screen-switcher h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.screen-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Fix screen switcher layout - Justify Space Between */
.screen-switcher {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* This pushes items to edges */
    gap: 2rem;
}