/* ============================================
   style.css - Desain QR Code Generator Surat (Desktop 16:9)
   ============================================ */

/* ============================================
   1. RESET & BASE STYLES
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #1a202c;
}

.container {
    max-width: 1200px; /* Diubah dari 500px menjadi 1200px */
    margin: 0 auto;
    padding: 24px 32px;
    background: #f7fafc;
    min-height: 100vh;
    border-radius: 24px;
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
}

/* ============================================
   2. HEADER
   ============================================ */

header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: -24px -32px 24px -32px;
    padding: 40px 20px;
    border-radius: 0 0 30px 30px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

header h1 {
    color: white;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
}

header p {
    color: rgba(255,255,255,0.9);
    font-size: 16px;
    margin: 0;
}

/* ============================================
   3. FORM - LAYOUT 2 KOLOM (Desktop)
   ============================================ */

main {
    background: white;
    border-radius: 20px;
    padding: 32px 28px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

#qrForm {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 kolom */
    gap: 20px 24px;
}

#qrForm .form-group {
    margin-bottom: 0;
}

/* Full width untuk elemen tertentu */
#qrForm .form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    margin-bottom: 6px;
}

.form-group .required {
    color: #e53e3e;
    margin-left: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #f7fafc;
    color: #2d3748;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.form-group small {
    display: block;
    color: #718096;
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   4. FOLDER GROUP
   ============================================ */

.folder-group {
    display: flex;
    gap: 10px;
}

.folder-group select {
    flex: 1;
}

.folder-group button {
    padding: 12px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.folder-group button:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

#newFolderInput {
    display: none;
    gap: 10px;
    margin-top: 10px;
    align-items: center;
}

#newFolderInput input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
}

#newFolderInput button {
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#saveNewFolder {
    background: #48bb78;
    color: white;
}

#saveNewFolder:hover {
    background: #38a169;
}

#cancelNewFolder {
    background: #fc8181;
    color: white;
}

#cancelNewFolder:hover {
    background: #f56565;
}

/* ============================================
   5. GENERATE BUTTON - Full Width
   ============================================ */

#generateBtn {
    grid-column: 1 / -1;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#generateBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

#generateBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   6. RESULT AREA - 2 Kolom
   ============================================ */

#resultArea {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 2px solid #e2e8f0;
}

#resultArea h2 {
    color: #2d3748;
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
}

#qrDisplay {
    display: grid;
    grid-template-columns: 1fr 1.5fr; /* QR di kiri, info di kanan */
    gap: 32px;
    align-items: start;
    background: #f7fafc;
    padding: 32px;
    border-radius: 16px;
}

#qrCanvasContainer {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    justify-content: center;
    align-items: center;
}

#qrCanvasContainer img {
    width: 100%;
    max-width: 280px;
    height: auto;
    object-fit: contain;
}

#qrInfo {
    width: 100%;
    font-size: 14px;
    line-height: 1.8;
}

#qrInfo p {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    margin: 0;
    gap: 12px;
}

#qrInfo p:last-child {
    border-bottom: none;
}

#qrInfo strong {
    min-width: 130px;
    color: #4a5568;
    font-weight: 600;
    flex-shrink: 0;
}

#qrInfo span,
#qrInfo a {
    color: #2d3748;
    word-break: break-all;
}

#qrInfo a {
    color: #667eea;
    text-decoration: none;
}

#qrInfo a:hover {
    text-decoration: underline;
}

/* ============================================
   7. ACTION BUTTONS
   ============================================ */

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-buttons button {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

#downloadBtn {
    background: #48bb78;
    color: white;
}

#downloadBtn:hover {
    background: #38a169;
    transform: translateY(-2px);
}

#copyBtn {
    background: #4299e1;
    color: white;
}

#copyBtn:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

#copyUrlBtn {
    background: #ed8936;
    color: white;
}

#copyUrlBtn:hover {
    background: #dd6b20;
    transform: translateY(-2px);
}

#newBtn {
    background: #a0aec0;
    color: white;
}

#newBtn:hover {
    background: #718096;
    transform: translateY(-2px);
}

/* ============================================
   8. BOTTOM NAVIGATION - Tetap di bawah
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 14px 0 18px 0;
    box-shadow: 0 -2px 15px rgba(0,0,0,0.08);
    border-radius: 20px 20px 0 0;
    z-index: 100;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #a0aec0;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    gap: 4px;
    padding: 4px 24px;
}

.bottom-nav a:hover {
    color: #667eea;
}

.bottom-nav a.active {
    color: #667eea;
}

/* ============================================
   9. DATABASE PAGE - Desktop Layout
   ============================================ */

.filter-section {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 16px;
    margin-bottom: 24px;
    align-items: end;
}

.search-box {
    margin-bottom: 0;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    background: #f7fafc;
    transition: all 0.3s ease;
}

.filter-group {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}

.filter-group select {
    flex: 1;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 13px;
    background: #f7fafc;
    color: #2d3748;
}

.refresh-btn {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.refresh-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

/* ============================================
   10. TABEL - Lebar penuh
   ============================================ */

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 700px;
}

#dataTable thead {
    background: #f7fafc;
}

#dataTable th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

#dataTable td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}

#dataTable tr:hover {
    background: #f7fafc;
}

/* ============================================
   11. MODAL - Lebar lebih besar
   ============================================ */

.modal-content {
    max-width: 700px;
    padding: 40px 36px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
}

/* ============================================
   12. RESPONSIVE - Tablet
   ============================================ */

@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 20px;
        border-radius: 16px;
    }
    
    #qrForm {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    
    #qrDisplay {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

/* ============================================
   13. RESPONSIVE - Mobile
   ============================================ */

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .container {
        padding: 16px 12px 100px 12px;
        border-radius: 0;
        min-height: 100vh;
    }
    
    header {
        margin: -16px -12px 16px -12px;
        padding: 24px 16px;
        border-radius: 0 0 20px 20px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    header p {
        font-size: 13px;
    }
    
    main {
        padding: 20px 16px;
    }
    
    #qrForm {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    #qrForm .form-group.full-width {
        grid-column: 1;
    }
    
    #qrDisplay {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }
    
    #qrCanvasContainer img {
        max-width: 200px;
    }
    
    #qrInfo p {
        flex-direction: column;
        gap: 2px;
        padding: 10px 0;
    }
    
    #qrInfo strong {
        min-width: unset;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-buttons button {
        min-width: unset;
        padding: 14px;
    }
    
    /* Database Mobile */
    .filter-section {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .bottom-nav {
        max-width: 100%;
        gap: 0;
        justify-content: space-around;
    }
    
    .bottom-nav a {
        padding: 4px 12px;
        font-size: 11px;
    }
    
    .modal-content {
        padding: 20px 16px;
        max-width: 100%;
        margin: 10px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px 8px 90px 8px;
    }
    
    main {
        padding: 16px 12px;
    }
    
    #qrDisplay {
        padding: 16px;
    }
}

/* ============================================
   14. ANIMATIONS & UTILITY
   ============================================ */

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

#resultArea {
    animation: fadeIn 0.5s ease forwards;
}

#btnLoading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#btnLoading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 12px;
    background: #667eea;
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.folder-badge {
    display: inline-block;
    padding: 2px 12px;
    background: #edf2f7;
    color: #4a5568;
    border-radius: 20px;
    font-size: 12px;
}

/* Loading & Error States */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.error-state,
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.error-state button {
    margin-top: 12px;
    padding: 10px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 24px;
    padding: 12px;
}

.pagination button {
    padding: 10px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    color: #4a5568;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination button:hover:not(:disabled) {
    border-color: #667eea;
    color: #667eea;
}

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

/* Action Buttons in Table */
.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #edf2f7;
    color: #4a5568;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.detail-btn {
    background: #667eea;
    color: white;
}

.detail-btn:hover {
    background: #5a67d8;
}

.delete-btn {
    background: #fc8181;
    color: white;
}

.delete-btn:hover {
    background: #f56565;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f7fafc;
    border-radius: 12px;
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 16px;
}

.stats-bar strong {
    color: #2d3748;
}