/* ============ Global Styles ============ */
* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(rgba(0,0,0,0.35), rgba(0,0,0,0.35)), url('/static/images/background.png') center/cover no-repeat;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #f9f9f9;
    padding: 10px;
}

/* ============ Container & Layout ============ */
.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    padding: 32px 28px;
    width: min(90vw, 600px);
    color: #222;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
        width: min(95vw, 100%);
        border-radius: 12px;
        max-height: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
        width: 100%;
        margin: 10px;
    }
}

/* ============ Typography ============ */
h1 {
    margin: 0 0 20px 0;
    color: #1a1a1a;
    font-size: 1.8rem;
    word-break: break-word;
}

h2 {
    color: #444;
    margin: 24px 0 18px 0;
    font-size: 1.3rem;
    border-bottom: 2px solid #4caf50;
    padding-bottom: 10px;
}

p {
    color: #666;
    line-height: 1.5;
}

/* ============ Forms ============ */
form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    width: 100%;
}

label {
    font-size: 0.95rem;
    text-align: left;
    display: block;
    width: 100%;
    color: #333;
    font-weight: 500;
    margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="file"] {
    padding: 12px 14px;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 44px;  /* Better touch target */
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.12);
}

input[type="text"]:invalid:not(:placeholder-shown),
input[type="password"]:invalid:not(:placeholder-shown),
input[type="email"]:invalid:not(:placeholder-shown) {
    border-color: #e74c3c;
}

/* ============ File Upload ============ */
.file-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.file-upload-label {
    display: inline-block;
    background-color: #4caf50;
    color: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    width: 100%;
    text-align: center;
    min-height: 44px;  /* Better touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.file-upload-label:hover {
    background-color: #3a9b3f;
    transform: translateY(-2px);
}

.file-upload-label:active {
    transform: translateY(0);
}

.file-upload-name {
    font-size: 0.9rem;
    color: #555;
    word-break: break-word;
    min-height: 1.2em;
    margin: 8px 0;
    display: block;
    width: 100%;
}

/* ============ Buttons ============ */
button,
.nav-button,
.logout {
    padding: 12px 18px;
    background-color: #4caf50;
    color: white;
    border: 2px solid #4caf50;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    min-height: 44px;  /* Better touch target */
    min-width: 100px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover,
.nav-button:hover,
.logout:hover {
    background-color: #3a9b3f;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

button:active,
.nav-button:active {
    transform: translateY(1px);
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ============ Files Section ============ */
.files-section {
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f9f9f9;
    border-radius: 10px;
    border-left: 4px solid #4caf50;
}

.file-list,
ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.file-list li,
li {
    margin: 12px 0;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    border-left: 3px solid #4caf50;
    transition: all 0.2s ease;
}

.file-list li:hover,
li:hover {
    background-color: #f0f0f0;
    transform: translateX(4px);
}

.file-list a,
li a {
    text-decoration: none;
    color: #4caf50;
    font-weight: 600;
    word-break: break-word;
}

.file-list a:hover,
li a:hover {
    text-decoration: underline;
}

.empty-state {
    color: #999;
    margin: 0;
    font-style: italic;
    padding: 10px 0;
}

/* ============ Navigation ============ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.user-info h1 {
    margin: 0;
}

.nav-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-actions a,
.nav-actions button {
    font-size: 0.9rem;
    white-space: nowrap;
}

.logout {
    position: static;
    background-color: #e74c3c;
    border-color: #e74c3c;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.logout:hover {
    background-color: #c0392b;
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .nav-actions {
        width: 100%;
    }
    
    .nav-actions a,
    .nav-actions button {
        flex: 1;
        padding: 12px;
        font-size: 0.85rem;
    }
}

/* ============ Messages & Alerts ============ */
.flash-list {
    margin: 0 0 20px 0;
    padding: 0;
    list-style: none;
}

.flash-list li {
    color: #c0392b;
    font-size: 0.95rem;
    background-color: #fadbd8;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 8px;
    border-left: 4px solid #c0392b;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ Loading Indicator ============ */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(76, 175, 80, 0.3);
    border-radius: 50%;
    border-top-color: #4caf50;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

button.loading:disabled {
    background-color: #4caf50;
    opacity: 1;
}

/* ============ Links ============ */
a {
    text-decoration: none;
    color: #4caf50;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

a:hover {
    opacity: 0.8;
}

a.nav-button {
    color: white;
}

/* ============ Responsive Design ============ */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    form {
        gap: 12px;
    }
    
    button,
    .nav-button,
    .logout {
        width: 100%;
        min-width: unset;
    }
    
    .files-section {
        padding: 12px;
        margin-bottom: 16px;
    }
    
    .file-list li {
        margin: 8px 0;
        padding: 8px;
    }
}

/* ============ Tablet Optimization ============ */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        width: min(95vw, 500px);
    }
    
    form label {
        font-size: 1rem;
    }
    
    .files-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    
    .files-section:first-of-type {
        grid-column: 1 / -1;
    }
}

/* ============ Scrollbar Styling ============ */
.container::-webkit-scrollbar {
    width: 8px;
}

.container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.container::-webkit-scrollbar-thumb {
    background: #4caf50;
    border-radius: 10px;
}

.container::-webkit-scrollbar-thumb:hover {
    background: #3a9b3f;
}

/* ============ Print Styles ============ */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    button,
    .nav-actions,
    .logout,
    form {
        display: none;
    }
}
