body {
    font-family: sans-serif;
    margin: 20px;
    background-color: #f4f4f4;
}

h1 {
    color: #333;
    text-align: center;
}

#controls {
    text-align: center;
    margin: 20px 0;
}

#sort-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
    margin-bottom: 10px;
}

#sort-btn:hover {
    background-color: #1976D2;
}

#filter-controls {
    margin-top: 10px;
}

#filter-controls label {
    margin-right: 8px;
    font-size: 14px;
    color: #333;
}

#location-filter, #tags-filter {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: white;
    margin-right: 10px;
}

#search-controls {
    margin-top: 15px;
}

#search-controls label {
    margin-right: 8px;
    font-size: 14px;
    color: #333;
    font-weight: bold;
}

#search-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: white;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#search-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

#clear-search-btn {
    padding: 8px 15px;
    background-color: #9e9e9e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

#clear-search-btn:hover {
    background-color: #757575;
}

#clear-all-filters {
    padding: 10px 20px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

#clear-all-filters:hover {
    background-color: #1976D2;
}

/* Upload Modal Styles */
#upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1001;
    display: none;
    justify-content: center;
    align-items: center;
}

#upload-modal .modal-content {
    background-color: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

#upload-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#upload-modal .modal-header h2 {
    margin: 0;
    color: #333;
}

#upload-modal .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#upload-modal .close-btn:hover {
    background-color: rgba(0,0,0,0.1);
    border-radius: 50%;
}

#upload-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin: 0 auto;
    display: block;
}

#photo-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.photo-item {
    background-color: #fff;
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.photo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #2196F3;
}

.photo-item:focus {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

.photo-focused {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

.photo-item img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 10px;
}

.photo-item {
    position: relative; /* For absolute positioning of drag handle */
}

.drag-handle {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: grab;
    font-size: 12px;
    z-index: 10;
    user-select: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.drag-handle:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.9);
}

.photo-item.dragging .drag-handle {
    cursor: grabbing;
    opacity: 1;
}

.caption-container {
    display: flex;
    flex-direction: column;
    margin-top: 5px;
}

.button-container {
    display: flex;
    justify-content: flex-start;
    margin-top: 5px;
}

.caption-text {
    margin: 0;
    flex-grow: 1;
    font-size: 14px;
    color: #333;
}

.edit-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
    margin-left: 8px;
}

.edit-btn:hover {
    background-color: #45a049;
}

.date-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.location-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.meta-container {
    margin: 5px 0;
    font-size: 12px;
    color: #666;
}

#upload-area {
    margin: 20px auto;
    max-width: 600px;
}

#drop-zone {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    background-color: #f9f9f9;
    transition: all 0.3s ease;
}

#drop-zone:hover {
    border-color: #2196F3;
    background-color: #f0f8ff;
}

#drop-zone.dragging {
    border-color: #4CAF50;
    background-color: #e8f5e9;
}

#drop-zone p {
    margin: 0;
    color: #666;
    font-size: 16px;
}

#drop-zone p::before {
    content: "📤 ";
    font-size: 20px;
}

#upload-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    font-weight: bold;
}

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

/* Tags styling */
.tags-container {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    background-color: #e0e0e0;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    color: #333;
    display: inline-block;
}

.tag:hover {
    background-color: #d0d0d0;
    cursor: default;
}

/* Drag and drop reordering styles */
.photo-item.dragging {
    cursor: grabbing !important;
    z-index: 100;
    position: relative;
}

.photo-item.drag-over {
    border: 2px dashed #2196F3 !important;
    background-color: rgba(33, 150, 243, 0.1) !important;
    transform: scale(1.02);
    transition: transform 0.2s, background-color 0.2s;
}

.photo-item {
    cursor: grab;
    transition: transform 0.2s, border-color 0.2s;
}

.photo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.photo-item:active {
    cursor: grabbing;
}

/* Drag handle indicator */
.photo-item::before {
    content: '⋮⋮';
    position: absolute;
    top: 5px;
    right: 5px;
    color: #666;
    font-size: 12px;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

.photo-item:hover::before {
    opacity: 1;
}

.photo-item.dragging::before {
    opacity: 0;
}

/* Batch selection mode */
.batch-mode .photo-item {
    cursor: pointer;
}

.batch-mode .photo-item:hover {
    border-color: #2196F3;
    background-color: #f5f5f5;
}

.batch-mode .photo-item.selected {
    border-color: #4CAF50;
    background-color: #e8f5e8;
}

.photo-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    z-index: 10;
    display: none;
}

.batch-mode .photo-checkbox {
    display: block;
}

/* Batch tag modal */
#batch-tag-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}

#batch-tag-modal.active {
    display: flex;
}

.batch-tag-modal-content {
    background-color: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    padding: 20px;
}

.batch-tag-modal-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.batch-tag-modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.batch-tag-modal-body {
    margin-bottom: 20px;
}

.batch-tag-modal-body p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
}

.batch-tag-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

.batch-tag-input:focus {
    outline: none;
    border-color: #2196F3;
}

.batch-tag-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.batch-tag-modal-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

#batch-tag-cancel {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
}

#batch-tag-apply {
    background-color: #4CAF50;
    color: white;
}
