/* ===== MeAgain - Theme Styles ===== */
:root {
    /* Dark Theme (Default) */
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-secondary: #533483;
    --text-primary: #eee;
    --text-secondary: #a0a0b8;
    --text-muted: #6c6c80;
    --border: #2a2a4a;
    --success: #00c853;
    --danger: #ff1744;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --theme-icon: '🌙';
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #f0f2f5;
    --bg-input: #e8eaed;
    --accent: #e94560;
    --accent-hover: #d13152;
    --accent-secondary: #7b68ee;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #888888;
    --border: #dddddd;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    --theme-icon: '☀️';
}

/* Theme Transition */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Offline Mode */
.offline-mode .shared-items::before {
    content: "You're currently offline. Some features may be limited.";
    display: block;
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 10px;
    margin-bottom: 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}

/* Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 900;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.install-banner.show {
    transform: translateY(0);
}

.install-banner-content {
    flex: 1;
}

.install-banner-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.install-banner-actions {
    display: flex;
    gap: 10px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
}

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

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
}

.theme-toggle {
    position: absolute;
    right: -40px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: var(--bg-card);
}

.logo-icon {
    font-size: 2.5rem;
    animation: waddle 2s ease-in-out infinite;
}

@keyframes waddle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--accent), #ff9a9e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.tagline {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 1rem;
    font-style: italic;
}

/* ===== Main Layout ===== */
main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 768px) {
    main {
        grid-template-columns: 1fr 1fr;
    }
}

section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    border: 1px solid var(--border);
}

section h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 1.2rem;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    margin-bottom: 20px;
    gap: 4px;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tab-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.4);
}

.tab-btn:hover:not(.active) {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}

.form-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.form-select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent);
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

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

/* ===== File Drop Zone ===== */
.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    transition: all 0.3s;
    background: var(--bg-card);
    cursor: pointer;
}

.file-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.drop-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.file-drop-zone p {
    color: var(--text-secondary);
    margin: 4px 0;
}

.or-text {
    color: var(--text-muted) !important;
    font-size: 0.85rem;
}

.file-info {
    font-size: 0.8rem;
    color: var(--text-muted) !important;
    margin-top: 8px !important;
}

.selected-file {
    color: var(--success) !important;
    font-weight: 600;
    margin-top: 8px !important;
}

.file-select-btn {
    cursor: pointer;
    display: inline-block;
    margin: 8px 0;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 8px 16px;
    font-size: 0.85rem;
}

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-refresh {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-refresh:hover {
    background: var(--bg-input);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

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

/* ===== Section Header ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    margin-bottom: 0;
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* ===== Search & Filters ===== */
.filter-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    gap: 12px;
}

@media (min-width: 768px) {
    .filter-container {
        flex-direction: row;
    }
}

.search-container {
    display: flex;
    gap: 8px;
    flex: 2;
}

.category-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1rem;
}

.search-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ===== Item Cards ===== */
.shared-items {
    max-height: 80vh;
    overflow-y: auto;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.3s;
    overflow: hidden; /* Prevent content overflow */
}

.item-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(233, 69, 96, 0.15);
}

.highlight-item {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(233, 69, 96, 0); }
    100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0); }
}

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

.item-header-left, .item-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-type {
    background: var(--accent-secondary);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.item-category {
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.item-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.item-expires {
    color: var(--text-secondary);
    font-size: 0.75rem;
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 12px;
}

.expires-soon {
    color: var(--danger);
    font-weight: 600;
}

.item-content {
    word-break: break-word;
    color: var(--text-primary);
    line-height: 1.5;
}

.item-content p {
    white-space: pre-wrap;
}

.item-content a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.3s;
}

.item-content a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.file-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 6px;
}

/* ===== Preview Media ===== */
.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s;
    display: block;
    object-fit: contain; /* Maintain aspect ratio */
    margin: 0 auto; /* Center image */
}

.preview-image:hover {
    transform: scale(1.02);
}

.preview-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain; /* Maintain aspect ratio */
    margin: 0 auto; /* Center video */
}

/* ===== Item Actions ===== */
.item-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
}

.action-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--accent);
}

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

/* ===== Loading & Empty States ===== */
.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 20px;
    font-style: italic;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
}

.modal-backdrop {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.modal-backdrop img {
    max-width: 95%;
    max-height: 95vh;
    border-radius: 8px;
    object-fit: contain;
}

.image-modal-actions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 90%;
    width: 400px;
    position: relative;
    box-shadow: var(--shadow);
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

#qrcode-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#qrcode-container canvas {
    border: 8px solid white;
    border-radius: 4px;
}

.qr-url {
    word-break: break-all;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 10px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--accent);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Toast Notifications ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s;
    box-shadow: var(--shadow);
}

.toast-success {
    background: var(--success);
    color: white;
}

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

/* Notification Center */
.notification-center {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 300px;
    max-width: 90%;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
    animation: slideInNotification 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid var(--accent);
}

.notification-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.notification-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.notification-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

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

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

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

.notification-info {
    border-color: var(--accent);
}

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

@keyframes slideInNotification {
    from {
        transform: translateX(50px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 767px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    main {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .form-options {
        grid-template-columns: 1fr;
    }

    .item-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .item-header-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
    }

    .item-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .action-btn {
        text-align: center;
        padding: 8px 5px;
        font-size: 0.75rem;
    }

    .delete-btn {
        grid-column: span 2;
    }

    /* Improve touch targets for mobile */
    .btn, .action-btn, .tab-btn, .form-select, .search-button {
        min-height: 44px;
    }

    .search-input {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Better mobile modal */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 16px;
    }

    .image-modal-actions {
        bottom: 60px;
    }

    /* Adjust notification position for mobile */
    .notification-center {
        width: 90%;
        max-width: 90%;
    }

    /* Improve mobile scrolling */
    .shared-items {
        max-height: 70vh;
    }
}
