/* ============================================
   Pro_Url Web - Stylesheet
   ============================================ */

:root {
    --primary: #0078d4;
    --primary-hover: #106ebe;
    --danger: #d13438;
    --danger-hover: #a4262c;
    --success: #107c10;
    --bg: #f3f2f1;
    --card-bg: #ffffff;
    --text: #323130;
    --text-light: #605e5c;
    --border: #edebe9;
    --radius: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Search */
.search-box {
    display: flex;
    gap: 6px;
}

.search-box input {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    width: 300px;
    outline: none;
}

.search-box button {
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.search-box button:hover { background: rgba(255,255,255,0.35); }

/* Layout */
.container {
    display: flex;
    height: calc(100vh - 48px);
}

/* Left panel - form & data */
.panel-left {
    width: 520px;
    min-width: 400px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Right panel - thumbnails & preview */
.panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Form */
.form-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.form-row label {
    width: 80px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    flex-shrink: 0;
}

.form-row input,
.form-row textarea {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-row input:focus,
.form-row textarea:focus {
    border-color: var(--primary);
}

.form-row textarea {
    height: 60px;
    resize: vertical;
}

/* Buttons */
.btn {
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f3f2f1; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* URL link display */
.url-display {
    padding: 8px 16px;
    background: #faf9f8;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.url-display a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    word-break: break-all;
}

.url-display a:hover { text-decoration: underline; }

/* DBGrid table */
.table-section {
    flex: 1;
    overflow: auto;
    border-bottom: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: #faf9f8;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover { background: #f3f2f1; }

.data-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tr:hover { background: #f3f2f1; }
.data-table tr.active { background: #deecf9; }

/* Thumbnail grid */
.thumbnail-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.thumbnail-header {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    background: #faf9f8;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.thumb-card {
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
    background: #faf9f8;
}

.thumb-card:hover { border-color: var(--primary); transform: scale(1.03); }
.thumb-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,120,212,0.3); }

.thumb-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-card .thumb-id {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
}

.thumb-card.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 11px;
    text-align: center;
    padding: 8px;
}

/* Preview section */
.preview-section {
    border-top: 1px solid var(--border);
    background: #faf9f8;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 350px;
    overflow: hidden;
    position: relative;
}

.preview-section img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-placeholder {
    color: var(--text-light);
    font-size: 14px;
}

/* Status bar */
.status-bar {
    background: #f3f2f1;
    border-top: 1px solid var(--border);
    padding: 4px 16px;
    font-size: 12px;
    color: var(--text-light);
    display: flex;
    justify-content: space-between;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: 8px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h2 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal .btn-group {
    margin-top: 16px;
    justify-content: flex-end;
}

/* File input */
.file-upload {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-upload input[type="file"] {
    font-size: 13px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* Responsive */
@media (max-width: 900px) {
    .container { flex-direction: column; }
    .panel-left { width: 100%; min-width: auto; max-height: 50vh; }
    .search-box input { width: 180px; }
}
