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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Pulse animation for processing status */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Login Screen */
.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 10px;
}

.login-box p {
    color: #666;
    margin-bottom: 30px;
}

.login-box input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.2s ease;
}

.login-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.login-box button {
    width: 100%;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    min-height: 48px;
}

.login-box button:hover {
    background: #5a6fd6;
}

.login-box button:active {
    transform: scale(0.98);
}

.login-box button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4);
}

.error {
    color: #e74c3c;
    margin-top: 15px;
}

/* Main App Layout */
#app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #1e293b;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 200;
}

.sidebar .logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.sidebar .logo h2 {
    color: #667eea;
    font-size: 20px;
}

/* Nav Icons */
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-menu {
    list-style: none;
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-menu li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    margin: 2px 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 6px;
    min-height: 44px;
}

.nav-menu li:hover {
    background: rgba(255,255,255,0.1);
}

.nav-menu li:focus {
    outline: none;
    background: rgba(255,255,255,0.1);
    box-shadow: inset 0 0 0 2px #667eea;
}

.nav-menu li.active {
    background: #667eea;
}

.nav-text {
    font-size: 15px;
    font-weight: 500;
}

/* Close Sidebar Button */
.close-sidebar {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
    width: 40px;
    height: 40px;
}

.close-sidebar:hover {
    background: rgba(255,255,255,0.1);
}

.close-sidebar:focus {
    outline: none;
    box-shadow: 0 0 0 2px #667eea;
}

.close-sidebar svg {
    width: 24px;
    height: 24px;
}

/* Logout */
.logout {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.logout button {
    width: 100%;
    padding: 12px 20px;
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px;
}

.logout button:hover {
    background: rgba(255,255,255,0.15);
}

.logout button:focus {
    outline: none;
    box-shadow: 0 0 0 2px #667eea;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page h1 {
    color: #1e293b;
    margin-bottom: 24px;
    font-size: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.page-header h1 {
    margin-bottom: 0;
}

.page-header button {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px;
    white-space: nowrap;
}

.page-header button:hover {
    background: #5a6fd6;
}

.page-header button:active {
    transform: scale(0.98);
}

.page-header button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card h3 {
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
}

.stat-card.success .value { color: #22c55e; }
.stat-card.warning .value { color: #f59e0b; }
.stat-card.danger .value { color: #ef4444; }
.stat-card.info .value { color: #3b82f6; }

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

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

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: #64748b;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: #f8fafc;
}

/* Folders Grid */
.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.folder-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.folder-card .header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-card .header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    cursor: pointer;
    color: #1e293b;
}

.folder-card .header h3:hover {
    color: #667eea;
}

.folder-card .body {
    padding: 20px;
}

.folder-card .images-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}

.folder-card .images-preview img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.folder-card .actions {
    display: flex;
    gap: 10px;
}

.folder-card .actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.2s ease, transform 0.1s ease;
    min-height: 44px;
}

.folder-card .actions button:active {
    transform: scale(0.98);
}

.folder-card .actions button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
}

.folder-card .actions .upload-btn {
    background: #667eea;
    color: white;
}

.folder-card .actions .upload-btn:hover {
    background: #5a6fd6;
}

.folder-card .actions .delete-btn {
    background: #ef4444;
    color: white;
}

.folder-card .actions .delete-btn:hover {
    background: #dc2626;
}

/* Settings Container */
.settings-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Settings Form */
.settings-form {
    background: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.settings-form h2 {
    margin: 0 0 24px 0;
    font-size: 18px;
    color: #1e293b;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1e293b;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: vertical;
}

.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group textarea {
    min-height: 100px;
    line-height: 1.6;
}

.form-group label .hint {
    display: block;
    font-weight: 400;
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.settings-form > button {
    padding: 14px 32px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s ease, transform 0.1s ease;
    min-height: 48px;
}

.settings-form > button:hover {
    background: #5a6fd6;
}

.settings-form > button:active {
    transform: scale(0.98);
}

.settings-form > button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4);
}

/* Modal */
.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: 1000;
    padding: 16px;
}

.modal {
    background: white;
    padding: 32px;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 24px;
    color: #1e293b;
}

.modal .form-group {
    margin-bottom: 20px;
}

.modal .buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal .buttons button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s ease, transform 0.1s ease;
    min-height: 48px;
}

.modal .buttons button:active {
    transform: scale(0.98);
}

.modal .buttons button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
}

.modal .buttons .cancel {
    background: #e2e8f0;
    color: #475569;
}

.modal .buttons .cancel:hover {
    background: #cbd5e1;
}

.modal .buttons .confirm {
    background: #667eea;
    color: white;
}

.modal .buttons .confirm:hover {
    background: #5a6fd6;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge.success { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.failed { background: #fee2e2; color: #991b1b; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.inactive { background: #e2e8f0; color: #475569; }
.badge.processing { background: #dbeafe; color: #1e40af; }
.badge.manual { background: #f3e8ff; color: #7c3aed; }
.badge.skipped { background: #e2e8f0; color: #475569; }
.badge.scheduled { background: #e0e7ff; color: #4338ca; }

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filters select,
.filters input[type="date"],
.filters input[type="text"] {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    min-height: 44px;
    background: white;
    transition: border-color 0.2s ease;
}

.filters input[type="text"] {
    min-width: 200px;
}

.filters select:focus,
.filters input[type="date"]:focus,
.filters input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.filters select {
    min-width: 180px;
    cursor: pointer;
}

.filters button {
    padding: 12px 20px;
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px;
    transition: background 0.2s ease;
}

.filters button:hover {
    background: #16a34a;
}

.filters button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.4);
}

/* Select */
select {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    min-height: 44px;
    transition: border-color 0.2s ease;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Action buttons */
.action-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    margin-right: 6px;
    transition: opacity 0.2s ease, transform 0.1s ease;
    min-height: 36px;
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.2);
}

.action-btn.edit { background: #3b82f6; color: white; }
.action-btn.edit:hover { background: #2563eb; }
.action-btn.test { background: #22c55e; color: white; }
.action-btn.test:hover { background: #16a34a; }
.action-btn.delete { background: #ef4444; color: white; }
.action-btn.delete:hover { background: #dc2626; }
.action-btn.settings { background: #8b5cf6; color: white; padding: 8px; }
.action-btn.settings:hover { background: #7c3aed; }
.action-btn.post { background: #f59e0b; color: white; padding: 8px; }
.action-btn.post:hover { background: #d97706; }
.action-btn.view { background: #10b981; color: white; text-decoration: none; }
.action-btn.view:hover { background: #059669; }

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #1e293b;
    color: white;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mobile-header h1 {
    font-size: 18px;
    margin-left: 12px;
    color: #667eea;
}

/* Hamburger Menu Button */
.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.menu-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px #667eea;
}

.menu-toggle span {
    display: block;
    height: 2px;
    width: 20px;
    background: white;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Responsive - Mobile First */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .close-sidebar {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
        padding: 80px 16px 24px 16px;
    }

    /* Better touch targets for nav */
    .nav-menu li {
        min-height: 48px;
        padding: 14px 16px;
    }

    /* Page header responsive */
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .page-header button {
        width: 100%;
    }

    /* Table responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 14px 12px;
        font-size: 14px;
    }

    /* Stats grid responsive */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .value {
        font-size: 24px;
    }

    /* Folders grid responsive */
    .folders-grid {
        grid-template-columns: 1fr;
    }

    /* Filters responsive */
    .filters {
        flex-wrap: wrap;
        width: 100%;
    }

    .filters select,
    .filters input[type="date"],
    .filters button {
        flex: 1;
        min-width: 140px;
    }

    /* Modal responsive */
    .modal {
        padding: 24px;
        border-radius: 12px;
    }

    /* Settings form responsive */
    .settings-container {
        grid-template-columns: 1fr;
    }

    .settings-form {
        padding: 24px;
    }

    /* Login box responsive */
    .login-box {
        margin: 16px;
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .folder-card .actions {
        flex-direction: column;
    }

    .folder-card .actions button {
        width: 100%;
    }

    .modal .buttons {
        flex-direction: column;
    }

    .filters {
        flex-direction: column;
    }

    .filters select,
    .filters input[type="date"],
    .filters button {
        width: 100%;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideIn 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.success { background: #22c55e; }
.toast.error { background: #ef4444; }
.toast.info { background: #3b82f6; }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Links in tables */
table a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s ease;
}

table a:hover {
    color: #5a6fd6;
    text-decoration: underline;
}

table a:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.4);
    border-radius: 4px;
}

/* Pagination - Professional styling */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 12px 12px;
}

.pagination-info {
    font-size: 14px;
    color: #64748b;
    white-space: nowrap;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-controls button {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-controls button:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.pagination-controls button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.4);
}

.pagination-controls button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-controls span {
    padding: 0 8px;
    color: #94a3b8;
    font-size: 14px;
}

.pagination-size {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-size select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    min-height: 36px;
    cursor: pointer;
    background: white;
    color: #475569;
}

.pagination-size select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

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

    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .pagination-size {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .pagination-controls button {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
}
