/* ============================================
   CSS RESET & BASE STYLES
   ============================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    
  letter-spacing: 1px;
}

html {
    height: 100%;
}

:root {
    --page-bg: #f6efe6;
    --surface: #fff8ee;
    --surface-alt: #f3e4cb;

    
    --text: #523311;
    --muted: #523311;
    --heading: #523311;


   
    --accent: #585a45;
    --accent-hover: #7f5323;
    --accent-soft: #efe0c1;
    --accent-2: #9e5919;
    --accent-2-hover: #8f6946;
    
    --copy: #af7c2f;
    --copy-hover: #9b7e54;
    
    --warning: #cca05f;
    --warning-hover: #b19b7a;


    --danger: #a1380e;
    --danger-hover: #843d31;
    --border: #d8c8ab;
    --shadow: rgba(74, 55, 34, 0.16);
    --shadow-strong: rgba(74, 55, 34, 0.22);
    --success: #6f7d4c;


    --font-header: 'Times New Roman', serif;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--page-bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

/* ============================================
   CONTAINER
   ============================================ */

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============================================
   LAYOUT
   ============================================ */

.main-content {
    flex: 1;
    padding-bottom: 60px;
    padding-top: 80px;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    background:  var(--accent);
    color: #fdf7ed;
    padding: 15px 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px var(--shadow);
    font-family: var(--font-header);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    margin: 0;
    font-size: 1.9rem;
    color: #fdf7ed;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo {
   width: 350px;
    display:block;
    margin: 0 auto;

}

.nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-link {
    color: #fdf7ed;
    text-decoration: none;
    padding: 5px 10px;
    transition: background-color 0.3s;
    text-align: center;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.logout-form {
    margin: 0;
}

.logout-button {
    background: none;
    border: none;
    color: #fdf7ed;
    cursor: pointer;
    padding: 5px 10px;
    font: inherit;
    text-align: center;
}

.logout-button:hover {
    text-decoration: underline;
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background:  var(--accent);
    color: #fdf7ed;
    padding: 15px 0;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px var(--shadow);
    font-family: var(--font-header);
}

.footer .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer p {
    margin: 0;
}

/* ============================================
   BUTTONS
   ============================================ */

.button {
    display: inline-block;
    padding: 10px 16px;
    background-color: var(--accent-2);
    color: #fffdf8;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    margin-bottom: 10px;
    transition: background-color 0.3s;
    text-align: center;
}

.button:hover {
    background-color: var(--accent-hover);
}

.btn-download {
    background-color: var(--accent-2);
}

.btn-copy {
    background-color: var(--copy);
}

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

.btn-download:hover {
    background-color: var(--accent-2-hover);
}

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

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

.delete-button {
    background-color: var(--danger);
}

.delete-button:hover {
    background-color: var(--danger-hover);
}

.secondary {
    background-color: #8f7b64;
}

.secondary:hover {
    background-color: #725e49;
}

.button.copied {
    background-color: var(--accent-2) !important;
}

/* ============================================
   ACTION BUTTONS GROUP
   ============================================ */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-buttons .button {
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
}

/* ============================================
   FILES PAGE
   ============================================ */

.files-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
}

.files-container h2 {
    margin-bottom: 20px;
    color: var(--heading);
}

.table-container {
    overflow-x: hidden;
    margin-top: 20px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Fixed column widths for the files table so data wraps instead of forcing a horizontal scroll */
.files-table th:nth-child(1),
.files-table td:nth-child(1) {
    width: 38%;
}

.files-table th:nth-child(2),
.files-table td:nth-child(2) {
    width: 14%;
}

.files-table th:nth-child(3),
.files-table td:nth-child(3) {
    width: 23%;
}

.files-table th:nth-child(4),
.files-table td:nth-child(4) {
    width: 25%;
}

/* Fixed column widths for the users (admin) table */
.users-table th:nth-child(1),
.users-table td:nth-child(1) {
    width: 35%;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
    width: 25%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
    width: 40%;
}

th {
    background-color: var(--surface-alt);
    font-weight: 600;
    color: var(--muted);
}

tr:hover {
    background-color: var(--surface-alt);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow);
    text-align: center;
}

.login-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.login-container h2 {
    margin-bottom: 20px;
    color: var(--heading);
}

.form-group {
    text-align: left;
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fffdf8;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(154, 107, 47, 0.2);
}

#loginForm .button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
}

/* ============================================
   ADD USER PAGE
   ============================================ */

.add-user-container {
    max-width: 500px;
    margin: 50px auto;
    padding: 30px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow);
}

.add-user-container h2 {
    margin-bottom: 20px;
    color: var(--heading);
    text-align: center;
}

.add-user-container .form-group {
    text-align: left;
    margin-bottom: 15px;
}

.add-user-container .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--muted);
}

.add-user-container .form-group input,
.add-user-container .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fffdf8;
}

.add-user-container .form-group input:focus,
.add-user-container .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(154, 107, 47, 0.2);
}

.add-user-container .button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
}

.add-user-container .secondary {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    display: inline-block;
}

/* ============================================
   ERROR PAGE
   ============================================ */

.error-container {
    max-width: 600px;
    margin: 50px auto;
    padding: 40px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow);
    text-align: center;
}

.error-icon {
    font-size: 64px;
    color: var(--danger);
    margin-bottom: 20px;
}

.error-container h2 {
    margin-bottom: 15px;
    color: var(--heading);
}

.error-message {
    background: #f8e6d9;
    color: var(--danger);
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
    font-size: 16px;
}

.error-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.error-actions .button {
    min-width: 120px;
}

/* ============================================
   UPLOAD AREA
   ============================================ */

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
    box-shadow: 0 2px 10px var(--shadow);
}

.upload-area.highlight {
    border-color: var(--accent);
    background-color: #fbf3e4;
}

.upload-area p {
    margin-bottom: 15px;
    color: var(--muted);
}

#selectFiles {
    cursor: pointer;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-container {
    background: var(--surface-alt);
    border-radius: 4px;
    margin: 15px 0;
    overflow: hidden;
}

.progress-bar {
    height: 20px;
    background: var(--accent-2);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    padding: 5px;
    font-size: 14px;
    color: var(--muted);
}

/* ============================================
   FILE LIST
   ============================================ */

#fileList {
    margin: 15px 0;
    text-align: left;
}

#fileList ul {
    list-style: none;
    padding: 0;
}

#fileList li {
    padding: 8px;
    background: #f9efe3;
    margin: 5px 0;
    border-radius: 4px;
}

#uploadButton {
    display: none;
}

/* ============================================
   ERROR MESSAGES (inline)
   ============================================ */

.success-message {
    background: #e3eed3;
    color: var(--success);
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #c2d3a3;
    text-align: left;
}

.error-message {
    background: #f8e6d9;
    color: var(--danger);
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #d8b49a;
    text-align: left;
}

/* ============================================
   RESPONSIVE STYLES - TABLET & MOBILE
   ============================================ */

@media screen and (max-width: 768px) {
    .files-container {
        padding: 10px;
    }
    
    .header .container {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .login-container,
    .add-user-container,
    .error-container {
        margin: 20px;
        padding: 20px;
    }
    
    /* Table responsive */
    table {
        border: 0;
    }
    
    table thead {
        display: none;
    }
    
    table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--border);
        border-radius: 4px;
    }
    
    table td {
        display: block;
        text-align: right;
        padding: 8px 15px;
        border-bottom: 1px solid var(--border);
    }
    
    table td:last-child {
        border-bottom: 0;
    }
    
    table td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-transform: uppercase;
        font-size: 12px;
        color: #888;
    }
    
    table td:last-child {
        text-align: left;
        padding-top: 10px;
    }
    
    table td:last-child::before {
        display: none;
    }
    
    /* Buttons full width on mobile */
    .button,
    .delete-button,
    .btn-download,
    .btn-copy,
    .btn-delete {
        display: block;
        margin: 5px 0;
        width: 100%;
        text-align: center;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .button {
        width: 100%;
    }
    
    .error-actions {
        flex-direction: column;
    }
    
    .error-actions .button {
        width: 100%;
    }
}

/* ============================================
   SMALL MOBILE
   ============================================ */

@media (max-width: 480px) {
    .login-container,
    .add-user-container {
        margin: 20px;
        padding: 20px;
    }
    
    .error-container {
        margin: 20px;
        padding: 20px;
    }
}

/* ============================================
   TREE VIEW STYLES
   ============================================ */

.files-layout {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.tree-sidebar {
    width: 250px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
    padding: 15px;
    height: fit-content;
    min-height: 400px;
}

.tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.tree-header h3 {
    margin: 0;
    color: var(--heading);
    font-size: 16px;
}

.btn-create-folder {
    padding: 8px 12px;
    font-size: 12px;
}

.tree-container {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.tree-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 8px;
}

.folder-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.folder-tree-children {
    list-style: none;
    padding: 0;
    margin: 6px 0 0 14px;
    border-left: 1px solid var(--border);
}

.folder-tree-item {
    margin: 2px 0;
}

.folder-tree-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.folder-tree-link {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    padding: 6px 8px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.folder-tree-link:hover {
    background: var(--surface-alt);
    color: var(--accent);
}

.folder-tree-link.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
}

.folder-tree-delete {
    border: 1px solid var(--danger);
    background: #f7dfd7;
    color: var(--danger);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}

.folder-tree-delete:hover {
    background: #f0c7b8;
    color: var(--danger-hover);
}

.folder-tree-label {
    word-break: break-word;
}

/* ============================================
   BREADCRUMB STYLES
   ============================================ */

.files-header {
    margin-bottom: 20px;
}

.files-header h2 {
    margin-bottom: 10px;
    color: var(--heading);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.breadcrumb-item {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb-item:hover {
    text-decoration: underline;
}

.current-breadcrumb-item {
    color: var(--heading);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--border);
}

.current-folder-info {
    margin-top: 10px;
    font-size: 14px;
    color: var(--muted);
}

.current-folder-info strong {
    color: var(--accent);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content-area {
    flex: 1;
    min-width: 0;
}

/* ============================================
   FILE ICONS
   ============================================ */

.file-icon {
    margin-right: 8px;
}

/* ============================================
   MODAL STYLES
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: var(--surface);
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-strong);
    width: 90%;
    max-width: 500px;
    box-sizing: border-box;
    animation: modalOpen 0.3s;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--heading);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    padding: 5px 10px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.modal-actions .button {
    min-width: 80px;
}

/* ============================================
   FORM STYLES FOR MODALS
   ============================================ */

.modal .form-group {
    margin-bottom: 15px;
}

.modal .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--muted);
}

.modal .form-group input,
.modal .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fffdf8;
}

.modal .form-group input:focus,
.modal .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(154, 107, 47, 0.2);
}

/* ============================================
   MOVE FILE BUTTON STYLES
   ============================================ */

.btn-move {
    background-color: var(--warning);
}

.btn-move:hover {
    background-color: var(--warning-hover);
}

.btn-create-folder {
    background-color: var(--accent-2);
}

/* ============================================
   RESPONSIVE STYLES FOR NEW LAYOUT
   ============================================ */

@media screen and (max-width: 768px) {
    .files-layout {
        flex-direction: column;
    }
    
    .tree-sidebar {
        width: 100%;
        order: 2;
    }
    
    .main-content-area {
        order: 1;
    }
    
    .breadcrumb {
        flex-wrap: wrap;
    }
    
    .modal-content {
        margin: 20px auto;
        width: 95%;
    }
    
    .action-buttons {
        flex-wrap: wrap;
    }
    
    .action-buttons .button {
        flex: 1;
        min-width: 70px;
    }
}
