/**
 * ORBAT System Styles
 * Styled after military organizational charts with hierarchical tree structure
 */

/* General Styling */
body {
    font-family: 'Arial', Helvetica, sans-serif;
    background-color: #f9f9f9;
    color: #333;
}

/* ORBAT Container */
.orbat-container {
    max-width: 1200px;
    margin: 20px auto;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.orbat-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #0066a2;
    font-size: 2em;
    border-bottom: 2px solid #0066a2;
    padding-bottom: 10px;
}

/* Refresh link for admins */
.refresh-link {
    text-align: right;
    margin: 10px 0 30px;
}

.refresh-link a {
    background-color: #0066a2;
    color: white;
    padding: 6px 12px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.refresh-link a:hover {
    background-color: #004e7c;
}

/* ORBAT Hierarchical Structure */
.orbat-content {
    margin-top: 15px;
    text-align: center;
    overflow: visible;
}

div.orbat {
    margin: 0;
    text-align: center;
    font-size: 16px;
    overflow: visible;
    width: 100%;
    position: relative;
    display: inline-block;
}

/* Command Section Styling */
.command-section-container {
    position: relative;
    display: block;
    margin: 0 auto 15px auto;
    text-align: center;
    padding-bottom: 15px;
    max-width: 300px;
}

.command-section {
    background-color: #f0f7ff;
    border: 1px solid #bbdefb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0 auto;
    padding: 8px;
}

.command-section h3 {
    background-color: #e1f5fe;
    padding: 6px 5px;
    margin: 0 0 10px 0;
}

/* Connect command section to troop header */
.command-section-container::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    height: 15px;
    width: 0;
    border-left: 2px solid #0066a2;
}

/* Connect command section to sections below */
.command-section-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    height: 15px;
    width: 0;
    border-left: 2px solid #0066a2;
}

/* For sections list that has a command section above */
.orbat ul.sections-list.with-command-section::before {
    display: none; /* Hide the original vertical line to troop */
}

/* Connect sections list to command section */
.orbat ul.sections-list.with-command-section {
    margin-top: 0;
    padding-top: 0;
}

/* List Structure */
.orbat ul {
    list-style-type: none;
    position: relative;
    margin: 0;
    padding: 15px 0 0 0;
    white-space: nowrap;
    display: inline-block;
    text-align: center;
    min-width: 100%;
}

.orbat ul.first {
    margin: 0 auto;
    text-align: center;
    white-space: normal;
    display: block;
    padding-top: 0;
}

/* Basic list item styling */
.orbat li {
    display: inline-block;
    vertical-align: top;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 15px 5px 0 5px;
    margin: 0 5px;
    white-space: normal;
    transition: all 0.1s;
}

.orbat li.troop-item {
    padding-top: 0;
    margin-bottom: 15px;
}

/* Section positioning */
.orbat li.section-item {
    padding-top: 15px;
}

/* Connect troop to sections */
.orbat ul.sections-list::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    height: 15px;
    width: 0;
    border-left: 2px solid #0066a2;
}

/* Connect section to its parent */
.orbat li.section-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    height: 15px;
    width: 0;
    border-left: 2px solid #0066a2;
}

/* For multiple sections, style the connectors */
.orbat li.first-section::after,
.orbat li.middle-section::after,
.orbat li.last-section::after {
    content: '';
    position: absolute;
    top: 0;
    width: 50%;
    height: 15px;
    border-top: 2px solid #0066a2;
}

/* For the first section in a group, draw right half of horizontal line */
.orbat li.first-section::after {
    left: 50%;
}

/* For the last section in a group, draw left half of horizontal line */
.orbat li.last-section::after {
    right: 50%;
    left: auto;
}

/* For middle sections, draw full horizontal line */
.orbat li.middle-section::after {
    left: 0;
    width: 100%;
}

/* Troop/Section Headers */
.orbat-troop {
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
    position: relative;
}

.orbat-troop h2 {
    display: inline-block;
    margin: 0 0 10px 0;
    color: #0066a2;
    font-weight: bold;
    font-size: 1.2em;
    text-align: center;
    background-color: #f5f9ff;
    padding: 6px 12px;
    border-radius: 5px;
    border-left: 4px solid #0066a2;
    border-right: 4px solid #0066a2;
    max-width: 100%;
    white-space: normal;
    word-wrap: break-word;
}

.orbat-section {
    background-color: #ffffff;
    border: 1px solid #e3e3e3;
    border-radius: 5px;
    margin: 5px auto;
    padding: 8px;
    display: block;
    vertical-align: top;
    width: 260px;
    min-height: auto;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s;
    text-align: left;
}

.orbat-section:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    border-color: #bbdefb;
    transform: translateY(-3px);
    transition: transform 0.3s, box-shadow 0.3s;
}

.orbat-section h3 {
    color: #0066a2;
    font-size: 1em;
    margin: 0 0 10px 0;
    padding: 6px 5px;
    text-align: center;
    background-color: #e3f2fd;
    border-radius: 3px;
    font-weight: bold;
    white-space: normal;
    word-wrap: break-word;
}

/* Members table */
.orbat-members {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    table-layout: fixed;
}

.orbat-members th {
    background-color: #0066a2;
    color: white;
    text-align: left;
    padding: 4px 6px;
    font-weight: bold;
}

.orbat-members td {
    padding: 3px 6px;
    border-bottom: 1px solid #eee;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

.orbat-members tr:nth-child(even) {
    background-color: #f7f7f7;
}

.orbat-members tr:hover {
    background-color: #e3f2fd;
}

/* Adjust column widths with ID and Account columns removed */
.member-rank {
    width: 30%;
    font-weight: bold;
}

.member-name {
    width: 40%;
}

.member-name a {
    color: #0066a2;
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 100%;
}

.member-name a:hover {
    text-decoration: underline;
    color: #004e7c;
}

.member-role {
    width: 30%;
    color: #555;
}

.no-members, .no-sections {
    font-style: italic;
    color: #888;
    padding: 10px;
    text-align: center;
}

/* Account indicator */
.has-account {
    color: #FFC107;
    margin-left: 5px;
    cursor: help;
    text-shadow: 0px 0px 1px #333;
}

/* Service Record Styling */
.service-record-container {
    max-width: 1000px;
    margin: 20px auto;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.service-record-container h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #0066a2;
    font-size: 2em;
    border-bottom: 2px solid #0066a2;
    padding-bottom: 10px;
}

.service-record-info {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 20px;
}

/* Account status section */
.account-status {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
}

.account-linked {
    border-left: 4px solid #4CAF50;
}

.account-unlinked {
    border-left: 4px solid #F44336;
}

.account-status-info {
    margin-bottom: 10px;
}

.account-owned {
    font-weight: bold;
    color: #0066a2;
}

/* Current Assignment Box */
.service-record-current {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.service-record-current::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 6px;
    background-color: #2a5928;
}

.service-record-current h2,
.service-record-history h2,
.service-record-awards h2,
.service-record-account h2 {
    color: #2a5928;
    border-bottom: 2px solid #2a5928;
    padding-bottom: 8px;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.current-info {
    width: 100%;
    border-collapse: collapse;
}

.current-info th, .current-info td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.current-info th {
    width: 25%;
    color: #555;
    font-weight: bold;
    vertical-align: top;
}

.current-info td {
    width: 75%;
}

/* Service History styling */
.service-record-history {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.service-record-history::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 6px;
    background-color: #3a7938;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.95em;
}

.history-table th {
    background-color: #0066a2;
    color: white;
    text-align: left;
    padding: 10px;
    font-weight: bold;
}

.history-table td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
}

.history-table tr:nth-child(even) {
    background-color: #f2f2f2;
}

.history-table tr:hover {
    background-color: #f0f7ff;
}

.history-date, .history-end {
    white-space: nowrap;
    width: 15%;
}

.history-unit {
    width: 20%;
}

.history-rank, .history-role {
    width: 15%;
}

.history-notes {
    width: 20%;
}

/* Awards styling */
.service-record-awards {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.service-record-awards::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 6px;
    background-color: #0066a2;
}

.awards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
}

.award-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    width: calc(33.333% - 20px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.award-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.award-item h4 {
    color: #0066a2;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.award-date {
    color: #777;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.award-description {
    margin-bottom: 10px;
    font-size: 0.95em;
}

.award-by {
    color: #555;
    font-size: 0.9em;
    font-style: italic;
    text-align: right;
    margin-top: 10px;
}

.no-awards {
    font-style: italic;
    color: #888;
    padding: 20px;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .orbat li {
        margin: 0 5px;
    }
    
    .orbat-section {
        width: 240px;
    }
    
    .award-item {
        width: calc(50% - 20px);
    }
}

@media (max-width: 900px) {
    .orbat-section {
        width: 220px;
    }
    
    .orbat-members {
        font-size: 0.8em;
    }
    
    .orbat li {
        margin: 0 3px;
    }
}

@media (max-width: 768px) {
    .orbat-container, .service-record-container {
        max-width: 95%;
        padding: 15px;
    }
    
    .orbat li {
        margin: 0;
    }
    
    /* Flatten tree structure on mobile */
    .orbat {
        display: block;
        text-align: center;
    }
    
    .orbat ul {
        display: block;
        white-space: normal;
        padding-top: 0;
    }
    
    .orbat li {
        display: block;
        width: 100%;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .orbat-section {
        width: 100%;
        max-width: 400px;
        min-height: auto;
        margin: 10px auto;
    }
    
    .orbat-members {
        font-size: 0.85em;
    }
    
    /* Hide all connecting lines on mobile */
    .orbat li:before, 
    .orbat li:after,
    .orbat ul:before,
    .orbat ul.sections-list:before {
        display: none;
    }
    
    /* Add visual space between troops */
    .orbat li.troop-item {
        margin-top: 20px;
        margin-bottom: 10px;
        border-top: 1px solid #ddd;
        padding-top: 20px;
    }
    
    .orbat li.troop-item:first-child {
        border-top: none;
    }
    
    /* Adjust heading sizes */
    .orbat-troop h2 {
        font-size: 1.2em;
        padding: 8px 12px;
    }
    
    .orbat-section h3 {
        font-size: 1em;
    }
    
    /* Service record mobile styles */
    .award-item {
        width: 100%;
    }
    
    .history-table, 
    .history-table thead, 
    .history-table tbody, 
    .history-table th, 
    .history-table td, 
    .history-table tr {
        display: block;
    }
    
    .history-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .history-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
    }
    
    .history-table td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
    }
    
    .history-table td:before {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
    }
    
    .history-table td:nth-of-type(1):before { content: "Date"; }
    .history-table td:nth-of-type(2):before { content: "Unit"; }
    .history-table td:nth-of-type(3):before { content: "Rank"; }
    .history-table td:nth-of-type(4):before { content: "Role"; }
    .history-table td:nth-of-type(5):before { content: "End Date"; }
    .history-table td:nth-of-type(6):before { content: "Notes"; }
    
    .service-record-header {
        flex-direction: column;
    }
    
    .member-info, .account-status {
        width: 100%;
    }
    
    .rank-badge {
        height: 60px;
        width: 60px;
        padding: 10px;
        font-size: 1em;
    }
    
    .service-record-footer {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* New Service Record Styling */
.service-record {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 20px;
}

.service-record-header {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.member-info {
    display: flex;
    background-color: #f5f9ff;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    flex: 1;
    min-width: 300px;
}

.member-info::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 6px;
    background-color: #0066a2;
}

.rank-badge {
    background-color: #0066a2;
    color: white;
    font-weight: bold;
    padding: 15px;
    border-radius: 50%;
    height: 80px;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    font-size: 1.2em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.member-name-info {
    flex: 1;
}

.member-name-info h2 {
    color: #2a5928;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.6em;
    border-bottom: 2px solid #2a5928;
    padding-bottom: 8px;
}

.member-role, .member-unit {
    margin: 5px 0;
    color: #555;
}

.member-role {
    font-weight: bold;
    font-size: 1.1em;
}

.account-status {
    flex: 1;
    min-width: 300px;
}

.service-record-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.service-record-timeline, 
.service-record-awards {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.service-record-timeline::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 6px;
    background-color: #0066a2;
}

.service-record-timeline h3,
.service-record-awards h3 {
    color: #0066a2;
    border-bottom: 2px solid #0066a2;
    padding-bottom: 8px;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.timeline {
    margin-top: 15px;
}

.service-record-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.join-date {
    color: #555;
    font-style: italic;
    margin: 0;
}

.back-to-orbat {
    background-color: #0066a2;
    color: white;
    padding: 8px 15px;
    border-radius: 3px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.back-to-orbat:hover {
    background-color: #004e7c;
    text-decoration: none;
}

/* Admin Drag & Drop Styling */
.is-admin .orbat-members tr.draggable {
    cursor: grab;
}

.is-admin .orbat-members tr.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.is-admin .orbat-members tr.selected {
    background-color: #e3f2fd !important;
    box-shadow: 0 0 0 2px #2196F3;
}

.is-admin .orbat-section.drop-target {
    background-color: #e8f5e9;
    box-shadow: 0 0 0 2px #4CAF50;
}

/* Role editing */
.is-admin .orbat-members .member-role {
    cursor: pointer;
    position: relative;
}

.is-admin .orbat-members .member-role:hover::after {
    content: "\270E";  /* Unicode pencil icon */
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: #777;
}

.is-admin .orbat-members .member-role .role-edit-input {
    width: 100%;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: inherit;
    font-size: inherit;
}

/* Admin Delete Button Styling */
.is-admin .orbat-section {
    position: relative;
}

.is-admin .orbat-troop h2 {
    position: relative;
}

.section-delete-btn,
.troop-delete-btn {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: rgba(220, 53, 69, 0.8);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s ease;
}

.section-delete-btn {
    top: 5px;
    right: 5px;
}

.troop-delete-btn {
    top: 50%;
    right: -10px;
    transform: translateY(-50%);
}

.is-admin .orbat-section:hover .section-delete-btn,
.is-admin .orbat-troop h2:hover .troop-delete-btn {
    display: block;
}

.section-delete-btn:hover,
.troop-delete-btn:hover {
    background-color: rgb(220, 53, 69);
    transform: scale(1.1) translateY(-45%);
} 