/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
    color: #2c3e50;
}

.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.admin {
    background-color: #e74c3c;
    color: white;
}

.badge.agent {
    background-color: #3498db;
    color: white;
}

/* Messages */
.error-message,
.success-message {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease-out;
}

.error-message {
    background-color: #fee;
    color: #c33;
    border-left: 4px solid #e74c3c;
}

.success-message {
    background-color: #efe;
    color: #3a3;
    border-left: 4px solid #27ae60;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: end;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.control-group select,
.control-group input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 200px;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: #3498db;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #27ae60;
    color: white;
}

.btn-primary:hover {
    background-color: #229954;
}

.btn-secondary {
    background-color: #3498db;
    color: white;
}

.btn-secondary:hover {
    background-color: #2980b9;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    font-size: 16px;
    color: #777;
}

/* Stats */
.stats {
    margin-bottom: 10px;
    padding: 10px 20px;
    background-color: #fff;
    border-radius: 6px;
    font-weight: 600;
    color: #555;
}

/* Table */
.table-container {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

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

thead {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody tr.done-row {
    opacity: 0.6;
    background-color: #e8f5e9;
}

/* Action buttons in table */
.action-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.checkbox-container {
    display: flex;
    align-items: center;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.undo-btn {
    padding: 4px 12px;
    font-size: 12px;
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.undo-btn:hover {
    background-color: #f57c00;
}

.undo-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

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

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group select,
    .control-group input {
        min-width: 100%;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 8px;
    }
}

/* Admin link */
.admin-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background-color: #9b59b6;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.admin-link:hover {
    background-color: #8e44ad;
}

/* Admin Specific Styles */
.admin-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-link,
.nav-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    background-color: #ecf0f1;
    color: #2c3e50;
}

.nav-link:hover,
.nav-btn:hover {
    background-color: #d5dbdb;
}

.nav-btn.active {
    background-color: #3498db;
    color: white;
}

.admin-section {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.card {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card h2,
.card h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group select {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background-color: #3498db;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% {
        width: 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

.template-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.template-info ul {
    list-style-position: inside;
    color: #555;
}

.template-info li {
    padding: 4px 0;
}

.items-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.item-checkbox {
    display: block;
    padding: 8px;
    margin: 4px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.item-checkbox:hover {
    background: #f5f5f5;
}

.item-checkbox input {
    margin-right: 8px;
}

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

    .admin-nav {
        flex-direction: column;
    }

    .nav-link,
    .nav-btn {
        width: 100%;
    }
}

.assignment-summary {
    padding: 8px;
    margin: 8px 0;
    background: #f9f9f9;
    border-left: 3px solid #007bff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 12px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 4px;
}

/* Batch action buttons */
.batch-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

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

.badge.active {
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.badge.inactive {
    background: #6c757d;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* Overall Progress Bar */
.overall-progress-bar {
    width: 100%;
    height: 8px;
    background-color: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 12px;
}

.overall-progress-bar .progress-fill {
    height: 100%;
    background-color: #27ae60;
    transition: width 0.5s ease-in-out;
    animation: none;
}

/* Agent Progress Section */
.agent-progress-section {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.agent-progress-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #2c3e50;
    font-size: 16px;
    padding: 8px 0;
    user-select: none;
}

.agent-progress-header:hover {
    color: #3498db;
}

.toggle-icon {
    font-size: 12px;
    transition: transform 0.2s;
}

.agent-progress-content {
    margin-top: 15px;
}

.agent-progress-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.agent-progress-table thead {
    background-color: #f8f9fa;
}

.agent-progress-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #555;
    text-transform: uppercase;
    border-bottom: 2px solid #dee2e6;
}

.agent-progress-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.agent-progress-table tbody tr:hover {
    background-color: #f8f9fa;
}

.agent-progress-table .done-count {
    color: #27ae60;
    font-weight: 600;
}

.agent-progress-table .pending-count {
    color: #e67e22;
    font-weight: 600;
}

/* Agent Progress Bar */
.agent-progress-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-progress-bar {
    flex: 1;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    min-width: 100px;
}

.agent-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    transition: width 0.5s ease-in-out;
    animation: none;
}

.agent-progress-bar .progress-fill.complete {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.progress-percent {
    font-weight: 600;
    font-size: 13px;
    color: #555;
    min-width: 40px;
    text-align: right;
}

/* Responsive adjustments for agent progress */
@media (max-width: 768px) {
    .agent-progress-table th,
    .agent-progress-table td {
        padding: 8px;
        font-size: 12px;
    }
    
    .agent-progress-bar {
        min-width: 60px;
    }
    
    .agent-progress-bar-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}
