/* App-specific styles for Card Maker */
:root {
    --theme-primary: #8E44AD;
    --theme-primary-light: #A569BD;
    --theme-primary-dark: #7D3C98;
    --theme-secondary-accent: #9B59B6;
    --theme-primary-bg: #F8F4FF;
    --theme-secondary-bg: #F0E6FF;
    --theme-text-on-primary: #ffffff;

    --app-bg-main: #FFFFFF;
    --app-bg-page: var(--theme-primary-bg);
    --app-bg-sidebar: var(--theme-secondary-bg);
    --app-text-secondary: var(--theme-primary-dark);
    --app-border-color: #E8D9F5;
    --app-btn-disabled-bg-new: #D3C0E1;
    --app-btn-disabled-text-new: #8A729A;
}

main > .page-section:first-of-type {
    background-color: var(--app-bg-page);
}

.app-container {
  border: 1px solid var(--app-border-color);
  border-radius: 24px;
  overflow: hidden;
  background-color: var(--app-bg-main);
  text-align: left;
  transition: all 0.3s ease-in-out;
}
.app-header {
  display: grid;
  grid-template-columns: 1fr 13fr 1fr;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background-color: var(--theme-primary);
  color: var(--theme-text-on-primary);
  border-bottom: 1px solid var(--theme-primary-dark);
}
.app-header-title {
    grid-column: 2;
    text-align: center;
    padding: 0 1rem;
}
.app-header .btn-icon {
    justify-self: end;
}
.app-header h2 {
    font-size: 1.2rem;
    margin: 0;
}

/* Main layout: 2/3 and 1/3 ratio */
.app-main {
  display: grid;
  grid-template-areas:
    "sidebar content"
    "actions content";
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr auto;
}

.app-sidebar {
    grid-area: sidebar;
    padding: 1.5rem;
    border-right: 1px solid var(--app-border-color);
    background-color: var(--app-bg-sidebar);
}
.app-content {
    grid-area: content;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}
.actions-section {
    grid-area: actions;
    padding: 1.5rem;
    border-right: 1px solid var(--app-border-color);
    background-color: var(--app-bg-sidebar);
}

.app-sidebar section, .app-content section, .actions-section {
  margin-bottom: 1rem;
}
.app-sidebar h3, .app-content h3, .actions-section h3 {
  font-size: 1.1rem;
  border-bottom: 2px solid var(--theme-primary);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.actions-section {
    margin-bottom: 0;
}


/* Content Area (Input) */
.input-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.input-section .form-group {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.input-section label {
    margin-bottom: 0;
}
.input-section textarea {
    width: 100%;
    flex-grow: 1;
    min-height: 200px;
    padding: 0.75rem;
    border: 1px solid var(--app-border-color);
    border-radius: 24px;
    font-family: inherit;
    resize: vertical;
    background-color: #ffffff;
}
.word-counter {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--app-text-secondary);
}
.word-counter span {
    font-weight: 600;
}

/* Sidebar (Settings & Actions) */
.excel-info-box {
    margin-bottom: 1rem;
}

.tip-section {
    padding-top: 1rem;
    border-top: 1px solid var(--app-border-color);
}

.actions-message {
    min-height: 50px;
    margin-bottom: 0.5rem;
    border: 1px dashed transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    padding: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}
.app-actions {
    display: flex;
    gap: 0.5rem;
}
.app-actions .btn {
    flex: 1;
}
.app-actions .btn-primary {
    background-color: var(--theme-primary);
    color: var(--theme-text-on-primary);
}
.app-actions .btn-primary:hover {
    background-color: var(--theme-primary-dark);
}

.app-container .btn:disabled,
.app-container .btn-primary:disabled,
.app-container .btn-secondary:disabled {
  background-color: var(--app-btn-disabled-bg-new);
  color: var(--app-btn-disabled-text-new);
  border-color: transparent;
  opacity: 1;
}

.settings-section {
    flex-shrink: 0;
}
.btn-group {
    display: flex;
    width: 100%;
    gap: 0.5rem; /* Add gap between buttons */
}
.btn-group .btn {
    flex: 1;
    border: 1px solid var(--app-border-color);
    background-color: #fff;
    color: var(--text-color);
}
.btn-group .btn.is-active {
    background-color: var(--theme-primary);
    color: var(--theme-text-on-primary);
    border-color: var(--theme-primary);
}
.btn-group .btn:hover:not(.is-active) { background-color: var(--app-bg-sidebar); }

.size-info-container { margin-top: 1rem; }
.info-box { display: flex; gap: 1rem; padding: 1rem; background-color: #ffffff; border-radius: 24px; font-size: 0.85rem; line-height: 1.4; border-left: 4px solid var(--theme-primary); }
.info-box.size-info { border-left-color: var(--app-text-secondary); }
.info-box.size-info.is-active { border-left-color: var(--theme-primary); }
.info-box i { font-size: 1.5rem; color: var(--theme-primary); margin-top: 0.25rem; }
.info-box p { margin: 0; }
.info-box a { color: var(--theme-primary); font-weight: 600; }
.size-info-desc { font-size: 0.8rem; margin-top: 0.25rem; }


/* Focus Mode */
body.focus-mode-active { overflow: hidden; }
body.focus-mode-active .site-header,
body.focus-mode-active .site-footer,
body.focus-mode-active main > *:not(#app-section-wrapper) { display: none; }
body.focus-mode-active #app-section-wrapper { padding: 0; background-color: transparent; }
body.focus-mode-active #app-section-wrapper .container { max-width: none; padding: 0; }
.app-container.is-focused { border-radius: 0; border: none; display: flex; flex-direction: column; width: 100%; }
.app-container.is-focused .app-main { flex-grow: 1; min-height: 0; grid-template-columns: 3fr 2fr; } /* New 3/5 to 2/5 ratio */
.btn-icon { background: none; border: 1px solid transparent; border-radius: 50%; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--theme-text-on-primary); cursor: pointer; transition: background-color 0.2s ease; }
.btn-icon:hover { background-color: rgba(255, 255, 255, 0.1); }
.btn-icon .fa-compress { display: none; }
.app-container.is-focused .btn-icon .fa-expand { display: none; }
.app-container.is-focused .btn-icon .fa-compress { display: inline-block; }


/* === Unified Responsive Styles === */

/* Large desktops */
@media (min-width: 768px) {
    .app-container:not(.is-focused) .app-header {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .app-container.is-focused {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%; /* More reliable than 100vw */
        height: calc(var(--vh, 1vh) * 100); /* Fix for vh units */
        z-index: 2000;
    }
    
    .app-container.is-focused .app-sidebar {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        overflow-y: auto;
    }

    .app-container.is-focused .app-content {
        overflow-y: auto;
    }

    /* Remove margin from top section in focus mode to let justify-content work cleanly */
    .app-container.is-focused .settings-section {
        margin-bottom: 0;
    }


    /* Make layout more compact vertically */
    .app-sidebar,
    .app-content,
    .actions-section {
        padding: 1rem;
    }
    
    .app-container.is-focused .app-sidebar,
    .app-container.is-focused .app-content {
        padding-left: 4rem;
        padding-right: 4rem;
    }

    .app-sidebar section, .app-content section, .actions-section {
        margin-bottom: 1rem;
    }

    .app-sidebar h3, .app-content h3, .actions-section h3 {
        margin-bottom: 0.75rem;
    }

    .excel-info-box {
        margin-bottom: 1rem;
    }

    .tip-section {
        padding-top: 1rem;
    }
}

@media (min-width: 768px) and (max-width: 992px) {
    .info-desktop-text {
        display: none;
    }
}

/* Mobile */
@media (max-width: 768px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "content"
      "actions";
    grid-template-rows: auto;
  }
  .app-container.is-focused .app-main {
      grid-template-columns: 1fr;
  }
  .app-sidebar, .actions-section {
    border-right: none;
  }
   .app-sidebar {
    border-bottom: 1px solid var(--app-border-color);
  }
  .input-section { flex-grow: 0; }
  body.focus-mode-active { overflow: auto; }
  .app-container.is-focused {
      position: static;
      height: auto;
      min-height: calc(var(--vh, 1vh) * 100);
  }

  .btn-group,
  .app-actions {
      flex-direction: column;
  }
}

/* Card maker status messages */
.actions-message:not(:empty) {
    border-style: solid;
    border-width: 1px;
}
.actions-message.actions-message--success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}
.actions-message.actions-message--error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}
.actions-message.actions-message--info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}