/* style.css (ฉบับสมบูรณ์) */

/* --- Base Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem 0;
}

.form-container, .container {
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
    box-sizing: border-box;
}

.container {
    max-width: 600px;
}
.container-medium {
    max-width: 800px;
}

h2 {
    text-align: center;
    color: #1d2129;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1rem;
}

.btn {
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: 6px;
    background-color: #1877f2;
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    background-color: #166fe5;
}

.btn-danger {
    background-color: #dc3545;
}
.btn-danger:hover {
    background-color: #c82333;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    text-align: center;
}

p {
    text-align: center;
    margin-top: 1rem;
}

a {
    color: #1877f2;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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


/* --- Admin Page Styles --- */
.admin-container {
    max-width: 1200px;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: #fff;
    table-layout: fixed;
}

th, td {
    padding: 12px 15px;
    border: 1px solid #ddd;
    text-align: left;
    word-wrap: break-word;
}

th {
    background-color: #f4f6f8;
    font-weight: 600;
}

tbody tr:hover {
    background-color: #f1f1f1;
    cursor: pointer;
}

.actions {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.btn-edit, .btn-delete, .btn-secondary {
    padding: 5px 10px;
    font-size: 0.9rem;
    width: auto;
    display: inline-block;
    white-space: nowrap;
}

.btn-edit { background-color: #ffc107; color: #212529; }
.btn-delete { background-color: #dc3545; }
.btn-secondary { background-color: #6c757d; }

.success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
    padding: .75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: .25rem;
}

/* --- Detail Page & QR Code Styles --- */
.file-details { list-style-type: none; padding: 0; }
.file-details li { margin-bottom: 1rem; background: #f9f9f9; padding: 10px; border-radius: 6px; }
.file-details strong { display: block; color: #555; margin-bottom: 5px; }
.file-details span, .file-details a { word-break: break-all; }
.actions-group { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2rem; border-top: 1px solid #eee; padding-top: 2rem; }

.qr-code-container {
    margin-top: 2rem;
    text-align: center;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 6px;
}
.qr-code-container h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #333;
}
.qr-code-container img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    padding: 5px;
    background: #fff;
}
.qr-code-container .btn {
    margin-top: 1.5rem;
    width: auto;
    padding: 10px 20px;
}

/* --- Table Column Widths --- */
.col-num { width: 8%; }
.col-clicks { width: 10%; }
/* URL Table */
.col-title { width: 52%; }
.col-url-short { width: 25%; }
/* File Table */
.col-file-name { width: 52%; }
.col-date { width: 25%; }
/* Actions column */
.col-actions {
    width: 15%;
    min-width: 160px;
}


/* --- Responsive Table for Mobile --- */
@media screen and (max-width: 768px) {
    table { border: 0; }
    table thead { display: none; }
    table tr {
        display: block;
        margin-bottom: .625em;
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    table td {
        display: block;
        text-align: right;
        border-bottom: 1px dotted #ccc;
    }
    table td:last-child { border-bottom: 0; }
    table td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
    }
    .actions { justify-content: flex-end; }
}