/* assets/css/style.css */
:root {
    --primary-color: #07C160;
    --bg-color: #EDEDED;
    --white: #FFFFFF;
    --text-primary: #111111;
    --text-secondary: #7F7F7F;
    --border-color: #DCDCDC;
    --header-height: 44px;
    /* Standard WeChat header height */
    --nav-height: 50px;
}

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

html,
body {
    background-color: #EDEDED;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    max-width: 680px;
    height: calc(var(--header-height) + env(safe-area-inset-top));
    background: #F7F7F7;
    /* Match WeChat header/tab style */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: env(safe-area-inset-top) 15px 0;
    z-index: 1000;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 500;
    flex: 1;
    text-align: center;
}

.header-left,
.header-right {
    width: 80px;
}

.header-left {
    text-align: left;
}

.header-right {
    text-align: right;
}

.header-btn {
    border: none;
    background: none;
    color: #576B95;
    font-size: 14px;
    cursor: pointer;
    padding: 5px;
}

.header-btn i {
    margin-right: 3px;
}

#publish-btn {
    background: none;
    border: none;
    font-size: 18px;
    /* Icon size */
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
}

/* Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    max-width: 680px;
    height: 50px;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box;
    background: #F7F7F7;
    border-top: 1px solid #D6D6D6;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
}

.bottom-nav::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #F7F7F7;
}

/* Background spill-over handled by html gradient */

.nav-item {
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    cursor: pointer;
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary-color);
}

/* Pages */
.page {
    padding: 10px;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 16px;
    width: 100%;
    margin: 10px 0;
}

.btn-success {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    transition: opacity 0.2s;
}

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

/* Forms */
input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}

/* Max Width Constraint */
body {
    max-width: 680px;
    margin: 0 auto;
    background-color: #333;
    /* Dark background for outside area */
}

#app {
    max-width: 680px;
    margin: 0 auto;
    background: #EDEDED;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    border-left: 1px solid #DCDCDC;
    /* Added border */
    border-right: 1px solid #DCDCDC;
    /* Added border */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* Enhanced shadow for contrast against dark body */
}

.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

/* Placeholder Page Styles */
.placeholder-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #EDEDED;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.placeholder-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #F7F7F7;
    border-bottom: 1px solid #D6D6D6;
}

.placeholder-header .logo {
    font-size: 18px;
    font-weight: 500;
}

.login-trigger-btn {
    background: #07C160;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.placeholder-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: white;
}

.construction-card {
    text-align: center;
    padding: 40px 20px;
}

.construction-icon {
    font-size: 64px;
    color: #07C160;
    margin-bottom: 20px;
}

.construction-title {
    font-size: 24px;
    margin-bottom: 15px;
    color: #111;
}

.construction-subtitle {
    font-size: 16px;
    color: #7F7F7F;
}

.placeholder-footer {
    padding: 20px;
    text-align: center;
    font-size: 12px;
    color: #999;
    background-color: #F7F7F7;
    border-top: 1px solid #D6D6D6;
}

.placeholder-footer p {
    margin: 0;
}

.placeholder-footer a {
    color: #576B95;
    text-decoration: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

/* Updated Login Modal Style - Light Theme */
.modal-content {
    background: #FFFFFF;
    padding: 25px 25px 15px;
    border-radius: 8px;
    width: 290px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    color: #000;
    position: relative;
    overflow: hidden;
}

.modal-content h2 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 500;
    color: #000;
}

.modal-content input {
    background: #f5f5f5;
    border: none;
    color: #000;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 15px;
    outline: none;
}

.modal-content input:focus {
    background: #ebebeb;
}

.modal-content .close-modal {
    display: none;
}

.storage-stats {
    margin-top: 15px;
    text-align: center;
    font-size: 13px;
    color: #888;
    background: #f9f9f9;
    padding: 10px 15px;
    border-radius: 6px;
    display: block;
    /* Changed to block */
    width: 100%;
    box-sizing: border-box;
}

.storage-stats b {
    color: #333;
    font-weight: 500;
}

.storage-stats i {
    margin-right: 5px;
    color: #07C160;
}

/* Dialog Buttons */
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    gap: 15px;
}

.btn-dialog {
    border: none;
    font-size: 14px;
    padding: 8px 24px;
    /* Wider buttons */
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.4;
    transition: opacity 0.2s;
}

.btn-dialog:active {
    opacity: 0.8;
}

.btn-dialog.cancel {
    background-color: #f2f2f2;
    color: #333;
}

.btn-dialog.confirm {
    background-color: #07C160;
    color: white;
    font-weight: 500;
}

/* Custom Styles for Image App (Adapting reference styles) */
.upload-area {
    margin: 15px;
}

.drop-zone {
    height: 200px;
    background: white;
    border: 1px dashed #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    cursor: pointer;
}

.drop-zone i {
    font-size: 64px;
    margin-bottom: 15px;
    color: #ccc;
}

.upload-list {
    margin-top: 15px;
}

.upload-card {
    background: white;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.upload-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    margin-right: 10px;
    border-radius: 4px;
    flex-shrink: 0;
}

.upload-info {
    flex: 1;
    overflow: hidden;
}

.upload-info .filename {
    font-weight: 500;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.format-tabs {
    display: flex;
    background: #f5f5f5;
    border-radius: 6px;
    padding: 3px;
    margin-bottom: 10px;
}

.format-tab {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: #666;
    padding: 6px 0;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.format-tab.active {
    background: white;
    color: #07C160;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.format-input-box {
    display: flex;
    background: #f5f5f5;
    border-radius: 4px;
    padding: 2px;
    align-items: center;
}

.format-input-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 12px;
    color: #333;
    padding: 6px 8px;
    outline: none;
    width: 0;
    /* Flex fix */
    margin: 0;
    /* Reset global input margin */
}

.mini-copy-btn {
    border: none;
    background: white;
    color: #07C160;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 3px;
    margin: 2px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mini-copy-btn:active {
    background: #f0f0f0;
}

.grid-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 0 15px;
}

.album-card {
    background: white;
    border-radius: 6px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.photo-item {
    aspect-ratio: 1;
    position: relative;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.settings-list {
    background: white;
    margin-top: 15px;
}

.setting-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}

.api-block {
    background: white;
    padding: 15px;
    margin-top: 15px;
    font-size: 13px;
}

.code {
    background: #f0f0f0;
    padding: 2px;
    border-radius: 2px;
    font-family: monospace;
}

/* WeChat-style Toast Notification */
#wechat-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#wechat-toast.show {
    opacity: 1;
}

#wechat-toast .toast-content {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    text-align: center;
    min-width: 120px;
}

#wechat-toast .toast-content i {
    display: block;
    font-size: 36px;
    margin-bottom: 10px;
    color: #07C160;
}

#wechat-toast .toast-msg {
    font-size: 14px;
}

/* Date Folder Browser */
.folder-list {
    padding: 0;
}

.folder-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.folder-item:active {
    background: #f5f5f5;
}

.folder-item i {
    font-size: 24px;
    color: #f5c542;
    margin-right: 15px;
}

.folder-item .folder-name {
    flex: 1;
    font-size: 16px;
    color: #333;
}

.folder-item .folder-count {
    color: #999;
    font-size: 14px;
}

.folder-header {
    display: flex;
    align-items: center;
    padding: 15px 15px;
    background: white;
    border-bottom: 1px solid #eee;
}

.folder-header .back-btn {
    border: none;
    background: none;
    color: #576B95;
    font-size: 14px;
    cursor: pointer;
}

.folder-header #current-folder-date {
    flex: 1;
    text-align: center;
    font-weight: 500;
}

.batch-btn {
    border: none;
    background: none;
    color: #576B95;
    font-size: 14px;
    cursor: pointer;
}

.batch-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.batch-actions span {
    color: #666;
    font-size: 14px;
}

.batch-delete-btn {
    border: none;
    background: none;
    color: #fa5151;
    font-size: 14px;
    cursor: pointer;
}

.batch-delete-btn i {
    margin-right: 5px;
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 3px;
}

.photo-item {
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image Detail Modal */
.image-detail-modal {
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

.image-detail-modal .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
}

.image-preview {
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.image-formats {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 20px;
}

.image-formats .format-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.image-formats .format-row:active {
    background: #e8e8e8;
}

.image-formats .format-row:last-child {
    border-bottom: none;
}

.image-formats .format-label {
    width: 70px;
    font-size: 12px;
    color: #999;
}

.image-formats .format-value {
    flex: 1;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-formats .format-copy {
    color: #07C160;
    font-size: 12px;
    cursor: pointer;
    margin-left: 10px;
}

.delete-btn {
    width: 100%;
    padding: 12px;
    background: #fa5151;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.delete-btn:active {
    background: #d84343;
}

/* Image Info in Modal */
.image-info {
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    color: #999;
}

.image-info i {
    margin-right: 5px;
}

/* Batch Selection in Photo Grid */
.photo-item.selectable {
    position: relative;
}

.photo-item.selectable::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
}

.photo-item.selected::after {
    background: #07C160;
    border-color: #07C160;
}

.photo-item.selected::before {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    color: white;
    font-size: 12px;
    text-align: center;
    line-height: 20px;
    z-index: 1;
}

/* WeChat-style Confirm Dialog */
.confirm-modal {
    z-index: 100000;
}

.confirm-content {
    background: white;
    border-radius: 12px;
    width: 280px;
    overflow: hidden;
    text-align: center;
}

.confirm-text {
    padding: 25px 20px;
    font-size: 16px;
    color: #333;
}

.confirm-actions {
    display: flex;
    border-top: 1px solid #eee;
}

.confirm-actions button {
    flex: 1;
    padding: 15px;
    border: none;
    background: white;
    font-size: 16px;
    cursor: pointer;
}

.confirm-cancel {
    color: #333;
    border-right: 1px solid #eee;
}

.confirm-ok {
    color: #fa5151;
    font-weight: 500;
}

.confirm-actions button:active {
    background: #f5f5f5;
}

/* API Page Styles */
.api-section {
    background: white;
    margin: 15px;
    padding: 20px;
    border-radius: 10px;
}

.api-section h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.api-desc {
    font-size: 13px;
    color: #999;
    margin: 0 0 15px 0;
}

.api-key-box {
    display: flex;
    background: #f5f5f5;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

.api-key-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px;
    font-size: 13px;
    font-family: monospace;
    color: #333;
}

.copy-key-btn {
    border: none;
    background: #07C160;
    color: white;
    padding: 12px 15px;
    cursor: pointer;
}

.copy-key-btn:active {
    background: #06a050;
}

.generate-key-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.generate-key-btn:active {
    background: #f5f5f5;
}

.generate-key-btn i {
    margin-right: 5px;
}

.api-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.api-info-row:last-child {
    border-bottom: none;
}

.api-label {
    font-size: 14px;
    color: #666;
}

.api-info-row code {
    font-size: 13px;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    color: #576B95;
}

.code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Settings Page Styles */
.settings-section {
    background: white;
    margin: 15px;
    border-radius: 10px;
    overflow: hidden;
}

.settings-header {
    padding: 10px 15px;
    font-size: 13px;
    color: #999;
    background: #f7f7f7;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item:active {
    background: #f5f5f5;
}

.setting-item i {
    color: #ccc;
    font-size: 12px;
}

.logout-item {
    justify-content: center;
    color: #fa5151;
}

/* Form Modal Styles */
.form-modal {
    width: 300px;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    border-bottom: 1px solid #eee;
}

.modal-desc {
    padding: 15px 20px 0;
    font-size: 13px;
    color: #999;
    margin: 0;
}

.form-group {
    padding: 15px 20px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #07C160;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.modal-actions {
    display: flex;
    border-top: 1px solid #eee;
}

.modal-actions button {
    flex: 1;
    padding: 15px;
    border: none;
    background: white;
    font-size: 16px;
    cursor: pointer;
}

.modal-cancel {
    color: #333;
    border-right: 1px solid #eee;
}

.modal-confirm {
    color: #07C160;
    font-weight: 500;
}

.modal-actions button:active {
    background: #f5f5f5;
}